[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

mpegvideo

MPEG Video Player

Name:

/usr/photon/bin/mpegvideo

Description:

The MPEG video player plugin, mpegvideo, is based on the Xing DVD Player. It plays MPEG-1 and MPEG-2 Video Layer streams.

Calling MvInit() sets the value of MvPluginCtrl_t.MvPluginFlags_t pflags to 0.

Resource profile utilization and library prerequisites

See the Resource Profile Estimates and Library Dependencies appendix.

Relevant commands

Valid commands for the MPEG video plugin are:

CMD_PLUGIN_CLOSE
CMD_PLUGIN_DIRECT_AUDIO
CMD_PLUGIN_GET_STATUS
CMD_PLUGIN_OPEN_URLS
CMD_PLUGIN_PAUSE
CMD_PLUGIN_SEEK_TO
CMD_PLUGIN_SET_PARAMETER
CMD_PLUGIN_START
CMD_PLUGIN_STOP

Environment variables

MPEGVIDEOBUFFERSIZE
Size of the input buffer (default is 500000).
MPEGVIDEOBUFFERSTARTPERCENT
Percent of the input buffer that needs to be filled before playing begins (default is 30).
MPEGVIDEOREFILLONUNDERFLOW
Refill the video input buffer to percent on underflow (default is OFF).

Examples:

The following sample callback handler is used by phplay to analyze state changes and status information. After verifying that the plugin handle is still valid, the value of the MvEventFlags_t change variable is examined to determine which field of the MvPluginStatus_t const *pst structure is valid.

Values that may be used for MvEventFlags_t change include:

MVS_DURATION
MVS_ERRORMSG
MVS_FLAGS
MVS_MEDIA
MVS_PLUGIN_STATE
MVS_POSITION
MVS_VPSIZE

void nogui_vcb( MvPluginCtrl_t *ctrl, MvEventFlags_t change, 
                MvPluginStatus_t const *pst )
{
    PtArg_t args[2];
    const char *status = "No plugin";
    if( mplayer.pctrl == NULL )
    { //this plugin has been closed
        if( pst->state == MV_DEAD )
    { // plugin is ready for destruction
            //fprintf(stderr,"in %s vcb() case MV_DEAD and mplayer.pctrl == NULL calling UnloadDll( ctrl )\n",__FILE__);
        UnloadDll( ctrl );
        free( ctrl );
        // reset plugin count
        mplayer.pluginIsLoaded = FALSE;
    }
        // show the correct pause/play button
         SetPlayPauseButton( TRUE );
        return;
    }
    
/* CHECK IF PLUGIN STATE HAS CHANGE */  
    if( change & MVS_PLUGIN_STATE )  
    { //plugin state has change
        MvCommandData_t cmdData = {0};
        switch( pst->state ) 
        {
            case MV_DEAD:
                status ="Dead";
                mplayer.pluginIsLoaded = FALSE;
                SetStopEjectButton( FALSE );
                //fprintf(stderr,"in %s vcb() case MV_DEAD calling cbBaseClose( 0, 0, 0 )\n",__FILE__);
                cbBaseClose( 0, 0, 0 );
                return;

            case MV_CLOSED:
                status = ( mplayer.pctrl->lastst == MV_OPENING ) ? "Open failed" : "No Clip";
                //fprintf(stderr,"in %s state = MV_CLOSED \n",__FILE__);
                break;
            
            case MV_OPENING:
                status = "Opening";
                //fprintf(stderr,"in %s state = MV_OPENING \n",__FILE__);
                break;

             case MV_STOPPED:
                status = ( mplayer.pctrl->lastst == MV_OPENING ) ? "Opened" : "Stopped";
                //mplayer.played = 0;
                //fprintf(stderr,"in %s state = MV_STOPPED \n",__FILE__);
                cmdData.pluginCtrl              = &mplayer.pctrl->mv;
                cmdData.cmdType                 = CMD_PLUGIN_SEEK_TO;
                cmdData.which                   = MVP_DELTA | MVP_POSITION;
                cmdData.param                   = &mplayer.playback_parms;
                mplayer.playback_parms.delta    = 0;
                mplayer.playback_parms.position = 0;
                mplayer.pctrl->mv.calls->command( &cmdData );
                if( mplayer.playIsSet )
                {
                    if( mplayer.pctrl->lastst == MV_OPENING && !mplayer.played )
                    {
                        //fprintf(stderr,"in %s state = MV_STOPPED calling PtTimerArm( ABW_pausePlayButton, 500  )\n",__FILE__);
                        PtTimerArm( ABW_pausePlayButton, 200  );
                    }
                } 
                break;

            case MV_PAUSED:
                status = "Paused";
                break;

            case MV_PREFETCHING:
                status = "Prefetching";
                break;

            case MV_PLAYING:
                status = "Playing";
                //fprintf(stderr,"in %s state = MV_PLAYING \n",__FILE__);
                mplayer.played = 1;
                break;
            
            default:
                status = "Unknown";
                break;
        }
        setbuttons( pst->state); 
        // update mplayer state flag 
        mplayer.pctrl->lastst = pst->state;
    }

/* CHECK IF PLUGIN STATUS FLAG HAS CHANGE */
    if( change & MVS_FLAGS )
    {// flags is valid. 
        mplayer.pctrl->psflags = pst->flags;
    }

/* CHECK IF PLUGIN WANT TO RESIZE VIDEO WINDOW */
    if( change & MVS_MEDIA )
  {
        if( mplayer.pctrl->lastst >= MV_STOPPED )
        {
        if( pst->media_info->which & MV_MEDIA_VIDEO_INFO )
        {
                mplayer.vin = *pst->media_info->video;
            if( pst->flags & MVS_AREA )
        {
            // set video window size to new value specified by plugin
            if( mplayer.playback_parms.video_wgt &&  mplayer.setup.videoSetting.bKeepAspectRatio && !mplayer.setup.bHomeEntertainment)
            {
                //fprintf(stderr,"Ang in %s resizing video window to x = %d y = %d w = %d h = %d\n",
            //__FILE__,mplayer.vin.area.pos.x,mplayer.vin.area.pos.y,mplayer.vin.area.size.w,mplayer.vin.area.size.h);
            PtSetArg( &args[0], Pt_ARG_DIM, &mplayer.vin.area.size, 0 );
            PtSetResources( ABW_video, 1, args );
            }
            return;
        }
        }
    }
    }

/* CHECK IF PLUGIN WANT TO ADJUST PHPLAY VOLUME SETTING */
  if( change & MVS_MEDIA )
  {
    if( pst->media_info->which & MV_MEDIA_AUDIO_INFO )
    {
      //fprintf(stderr,"Ang in %s plugin was volume change to %d\n",__FILE__,pst->media_info->audio->volume);
      PtSetArg( &args[0], Pt_ARG_GAUGE_VALUE, pst->media_info->audio->volume, 0 );
      PtSetResources( ABW_PtSlider_volume, 1, args );
      return;
    }
  }


/* CHECK IF PLUGIN MEDIA INFO IS VALID  */
    if( change & MVS_MEDIA ) //  media_info is valid and points to new media
    {   
        if( mplayer.pctrl->lastst >= MV_STOPPED ) 
        {// last state was MV_STOPPED or MV_PAUSED or MV_PREFETCHING or MV_PLAYING
            const char* title = pst->media_info->title;
            if( title == NULL )
            {
                title = ( title = strrchr( pst->media_info->url, '/' ) ) ? ++title : pst->media_info->url;
            }
            mplayer.pctrl->mediaType    = pst->media_info->type;
            mplayer.pctrl->duration     = pst->media_info->duration;

            //was if( mplayer.pctrl->mediaType & MV_MEDIA_VIDEO )
            if( pst->media_info->which & MV_MEDIA_VIDEO_INFO )
            {
            mplayer.vin = *pst->media_info->video;
            }

            if( mplayer.pctrl->mediaType & MV_MEDIA_SEEKABLE && mplayer.pctrl->duration )
            {
                //fprintf(stderr,"Ang in %s line %d resetting value to 0 resetting Pt_BLOCKED and Pt_GHOST flags\n",__FILE__,__LINE__);
                PtSetArg( &args[0], Pt_ARG_FLAGS, 0, Pt_BLOCKED | Pt_GHOST );
                PtSetResources( ABW_curpos, 1, args );
            }
            if( pst->media_info->type & MV_MEDIA_PLAYLIST )  
            { // the  plugin new media info is a play list 
                int track;
                ControllerGetPluginList();
                track = ControllerGetActiveTrack();
                ControllerOpenIndex( NULL, track );
            }
            else
            {
                int track;
                MvCommandData_t cmdData = {0};
                // the new plugin media info is not a play list 
                //track = ControllerAddUrl( pst->media_info->url, pst->media_info->title );
                //ControllerSetActiveTrack( track );
                PtSetArg( &args[0], Pt_ARG_TEXT_STRING, ControllerGetActiveUrl() , 0 );
                PtSetResources( ABW_baseInfo, 1, args );
                if( pst->media_info->duration )
                {
                    //adjust the maximum range of the progress bar widget 
                PtSetArg( &args[0], Pt_ARG_GAUGE_MAXIMUM, pst->media_info->duration, 0 );
                PtSetResources( ABW_curpos, 1, args );
                }
                // repositioning  of the widget to show beginning of time frame 
            PtSetArg( &args[0], Pt_ARG_GAUGE_VALUE, 0, 0 );
            PtSetResources( ABW_curpos, 1, args );

                if(( mplayer.playback_parms.status_frequency = mplayer.pctrl->duration / POS_SLIDER_WIDTH ) > 100 )
                {
                    mplayer.playback_parms.status_frequency = 100;
                }
                cmdData.pluginCtrl           = &mplayer.pctrl->mv;
                cmdData.cmdType              = CMD_PLUGIN_SET_PARAMETER;
                cmdData.which                = MVP_STATUS_FREQ | MVP_AUDIO;
                cmdData.param                = &mplayer.playback_parms;
                mplayer.pctrl->mv.calls->command( &cmdData );
            }
        }
        else
        {// last state was MV_DEAD or MV_CLOSED or MV_OPENING

            // reset GUI cursor position
            PtSetArg( &args[0], Pt_ARG_GAUGE_VALUE, 0, 0 );
            PtSetResources( ABW_curpos, 1, args );
            // make it impossible to move the cursor from the GUI   
            PtSetArg( &args[0], Pt_ARG_FLAGS, ~0, Pt_BLOCKED | Pt_GHOST );
            PtSetResources( ABW_curpos, 1, args );
        }
    }

/* CHECK IF PLUGIN POSITION  IS VALID */
    if( change & MVS_POSITION ) 
    { // position is valid 
        long    *value;
        long    *max;
        plassert( mplayer.pctrl->duration != 0, "MVS_POSITION is set even though duration is zero" );
        if( !( mplayer.cursorIsDrag ) ) 
        {
            // update background cursor position
            mplayer.pctrl->lastpos = pst->position;
            PtSetArg( &args[0], Pt_ARG_GAUGE_VALUE, pst->position, 0 );
            PtSetResources( ABW_curpos, 1, args );

            PtSetArg( &args[0], Pt_ARG_GAUGE_VALUE, &value, 0 );
            PtGetResources( ABW_curpos, 1, args );
            PtSetArg( &args[0], Pt_ARG_GAUGE_MAXIMUM, &max, 0 );
            PtGetResources( ABW_curpos, 1, args );
        }
    }

/* CHECK IF PLUGIN DURATION  IS VALID */
    if( change & MVS_DURATION ) 
    {
        //adjust the maximum range of the progress bar widget
        mplayer.pctrl->duration     = pst->duration;
        PtSetArg( &args[0], Pt_ARG_GAUGE_MAXIMUM, pst->duration, 0 );
        PtSetResources( ABW_curpos, 1, args );
    }

/* CHECK IF PLUGIN WANT TO CHANGE THE CLIENT AREA SIZE */
    if( change &  MVS_VPSIZE ) 
    { 
        PhDim_t isDim;
        PhDim_t toDim;

        toDim.w = pst->vpsize.w;
        toDim.h = pst->vpsize.h;
        //extract actual base window size
        PtWidgetDim(ABW_base, &isDim );

        if( isDim.w < toDim.w ) // requested width is bigger that actual base window width
        {
            // resizing of client area
            PtSetArg( &args[0], Pt_ARG_DIM, &toDim, 0 );
            PtSetResources( mplayer.playback_parms.spane_wgt, 1, args);
            // resizing of base window
            isDim.w = toDim.w;
            PtSetArg( &args[0], Pt_ARG_DIM, &isDim, 0 );
            PtSetResources( ABW_base, 1, args);
            
        }
        else  //requested width is smaller that the actual base window width
        {
            // check if requested width is bigger that minimum base window width    
            toDim.w = ( toDim.w > mplayer.baseDim.w ) ? toDim.w : mplayer.baseDim.w;
            //resizing of the client area
            PtSetArg( &args[0], Pt_ARG_DIM, &toDim, 0 );
            PtSetResources( mplayer.playback_parms.spane_wgt, 1, args); 
            // resizing of phplay base window
            isDim.w = isDim.w - ( isDim.w - toDim.w) ;
            PtSetArg( &args[0], Pt_ARG_DIM, &isDim, 0 );
            PtSetResources( ABW_base, 1, args);
        }
        PtExtentWidgetFamily( ABW_BaseGroup );
        PtRealizeWidget( ABW_BaseGroup );
    }

/* CHECK IF PLUGIN HAS AN ERROR MESSAGE */
    if( change & MVS_ERRORMSG ) 
    { // there's an error message in errmsg
        mplayer.bPluginError = TRUE;
        popup_error( pst->errormsg );
    }

/* CHECK IF PLUGIN IS WAITING FOR NEXT COMMAND */
    if(  mplayer.pctrl->lastst ==  MV_STOPPED  && mplayer.played )
  {
    mplayer.played  = 0;
        //fprintf(stderr,"In %s state = MV_STOPPED calling PtTimerArm( ABW_ControlGroup, 200  )\n",__FILE__);
        PtTimerArm( ABW_ControlGroup, 200  );
  }
}

[Previous] [Contents] [Next]