Friday, September 14, 2012

SYSTEM CLOCKS



CLOCK_REALTIME : it gives the access to the real time clock (RTC) , i.e. the one that stores the current date and time.

     A key difference between an RTC and the system clock is that RTCs run even
     when the system is in a low power state (cpu Idle), and the system  clock can't. 
     Until it is initialized, the system clock can only report time since system boot, not 
     since the POSIX Epoch.  So at boot time, and after resuming from a system low 
     power state, the system clock will often be set to the current wall clock time using 
     an RTC.



CLOCK_MONOTONIC : it gives the access to a clock ( cpu ticks ) that never goes back in time .It takes the CPU Hz.

 It goes off when there will be no Hz ( cpu Idle state) . So when again CPU gets up ,
 it adds the sleeping time using another components input timerkeeping timer,
 basically a rough time. So it should be used in the usecase wherever we need delta 
 of time.Irrespective of cpu state during playback , whenever we do clock_gettime ,this
 clock will be there.
Basically these are clock_ids which provides clock source when we use clock_gettime()

otherwise to get the phone time , we can use gettimeofday() , this will change whenever there
will be change in wall time.

Wednesday, September 12, 2012

Android Streaming



    Streaming on Android Phone
  • HTTP , PDL , Youtube 
  • HLS - Live streaming
  • DRM - Widevine
  • RTSP




 

Tuesday, September 11, 2012

Matrix


Q -1 Write a program to transpose the given 4 x 4 matrix  and count the number of swapping operation will be done.

program -

#include stdio.h
#include conio.h
int a[4][4];
inline int Transpose()
{
       int temp,l,m,c=0;
       for( l=0; l < 4 ; l ++) {
           for( m=0; m < 4 ; m++) {
               if(l  <  m) {
                 temp = a[l][m];
                 a[l][m] = a[m][l];
                 a[m][l] = temp;
                 c++;
                 }
                      
              }
              
       }
       printf("number of swaping : %d\n\n",c);
}

int main()
{
    int i,j;
    printf("Enter the matrix :");
    for (i =0;i < 4;i++)
    {
        for(j=0; j < 4; j++)
         {
                scanf("%d",&a[i][j]);
         }
    }
    printf ("Matrix 4x4:");
    for (i =0 ; i < 4; i++)
    {  
        printf("\n");
        for(j=0; j < 4; j++)
         {
                printf("%d",a[i][j]);
                printf("\t");
         }
         printf("\n");
    }
   Transpose();
   printf ("T_Matrix 4x4:");
    for (i =0 ; i < 4; i++)
    {  
        printf("\n");
        for(j=0; j < 4; j++)
         {
                printf("%d",a[i][j]);
                printf("\t");
         }
         printf("\n");
    }
    
getch();
return 0;
}


Q.2  c++ program to multiply two 4x4 matrix

for multiplication number of columns in A must be equal to number of rows in B  here m=n=4

Program : 

Sunday, September 9, 2012

program to count 1's in the given integer


Ref for Several BIT Manipulation type and techniques based Example  :

http://graphics.stanford.edu/~seander/bithacks.html

for ex :

Q 1. Write a program to count 1's in the given integer ?

Lets say we are using 32 bit  - little endian processor. User enters any integer value and we need to find the number of bit 1 in that integer.

Example: integer n =(10) base 10 equals to (0000 0000 0000 0000 0000 0000 0000 1010) base 2. so there are 2 1's bits in this . so the Output should be 2.

Program:

#include stdio.h
#include conio.h
int main()
{
      int a,b=1,c=0; //lets say a = 12
      printf("Enter the integer: ");
      scanf("%d",&a);
      while(a)
     {        
           if(a&b)
           c++;
           a=a>>1;
      }
      printf("number of 1: %d",c);
      getch();
      return 0;
}

// Note: it will change the Value of original provided integer to 0.




Saturday, September 8, 2012

Eins-Ten < PUZZLES >




PuzzleS  ;

1. How will you make 37 out of five 5's using them five times only with any operators.

Ans :  5!/(5+5) + (5x5)

2. Suppose you have a string of 15cm , you want to have minimum numbers of cut for this string
so that you can make any length strings using them.

Ans :  converting 15 to binary (1111) base 2 .  So we have set the 2power0 , 2power1, 2power2 , 2power3 bits i.e 8 ,4,2,1 . So there would be 3 cuts to get the 4 different strings of these sizes and we can make any size till 15. ex 8+4 =12 , 8+4+2=14,2+1=3 , 1,2,1+2=3  etc.

3. There are two doors Right A and Wrong B but not identified, and two guards are standing at those doors. One guard always lies whereas another say always truth. They know about each other behaviors. But you dont know their nature.So how will you identify the right door by asking any
one of them only one time in one chance.

Ans :   Since One Guard will always lie and Another one will always say truth. And they know each others nature. So you can ask any one of them : " Hey Buddy!! Which door will another Guard point, if  i will ask correct door from him?"

Since you dont know their nature , so you can ask anyone unknowingly. There could be two cases .
case 1 : Either you will ask from Guard who says truth , then he would say that another guard will point to B door( Wrong , as another Guard lies so he will not show you correct door).

case 2: Or you will from Guard who lies , then he would say that another guard will point to B door ( He know that another Guard says truth so he will point to correct door A , but this Guard always lies so he will say opposite of that and will point to door B i.e wrong)


for Both cases you got pointed to Wrong door B ,  so you go to another door which would be Correct A.