Cluster-based Video Player: Implementation

Implementation

MPI environment is initialized for nodes to communicate to each other. The nodes are instructed to display the image on their display screens by setting the DISPLAY environment variable to the value ‘localhost:0.0’ or simply ‘:0.0’. The X server running on the nodes allow the server to authenticate by disabling access control, which can be done by issuing the command ‘xhost +server’.

if(rank!=0){
      sprintf(buf,":0.0",proc_name);
    setenv("DISPLAY",buf, 1);
   }
lokilogo2.gif

We have used the SMPEG library to encode and decode the MPEG-1 videos.

SMPEG (SDL MPEG Player Library), originally developed by Loki Software is a free MPEG1 video player library with sound support.
The video playback is based on the Berkeley mpeg_play program whereas the audio support is achieved by using mpegsound library.

The advantage of using SMPEG library is that it interfaces easily with the Simple DirectMedia Layer (SDL) to provide cross-platform video display support.
The SMPEG is currently hosted at [http://icculus.org/smpeg/]

Loki - The Games that Linux People Play

if(rank==0)
    screen = SDL_SetVideoMode(1024, 768, video_bpp, video_flags);
else
    screen=SDL_SetVideoMode(800,600,video_bpp,video_flags);            

switch(rank){
    case 1:            
    SMPEG_setdisplayregion(mpeg, 0, 0, info.width/2, info.height/2);
    break;

    case 2:            
    SMPEG_setdisplayregion(mpeg, info.width/2, 0, info.width/2, info.height/2);
    break;

    case 3:            
    SMPEG_setdisplayregion(mpeg, info.width/2, info.height/2, info.width/2, info.height/2);
    break;

    case 4:            
     SMPEG_setdisplayregion(mpeg, 0, info.height/2, info.width/2, info.height/2);
    break;
          }

if ( screen == NULL ) {
    fprintf(stderr, "Unable to set %dx%d video mode: %s\n",
                                    width, height, SDL_GetError());
      continue;
                     }
    if ( screen->flags & SDL_FULLSCREEN ) {
        SDL_ShowCursor(0);
    }
    SMPEG_setdisplay(mpeg, screen, NULL, update);
    SMPEG_scaleXY(mpeg, screen->w, screen->h);
} else {
    SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

While the video is being played back , the server node waits for a keypress event from the user and sends the signal to the clients. The video synchronization across all the nodes is done using MPI_Barrier.

if (rank==0){
             MPI_Send(&done,1,MPI_INT,1,1,MPI_COMM_WORLD);
             MPI_Send(&done,1,MPI_INT,2,1,MPI_COMM_WORLD);
             MPI_Send(&done,1,MPI_INT,3,1,MPI_COMM_WORLD);
             MPI_Send(&done,1,MPI_INT,4,1,MPI_COMM_WORLD);
             }
    else
           MPI_Recv(&done,1,MPI_INT,0,1,MPI_COMM_WORLD,stat);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.