⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corba.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
                            CORBA_Environment * ev ){    mediacontrol_exit( servant->mc );    return;}static voidimpl_VLC_MediaControl_playlist_add_item( impl_POA_VLC_MediaControl * servant,                                         const CORBA_char * psz_file,                                         CORBA_Environment * ev ){    mediacontrol_Exception *exception = NULL;      MC_TRY;    mediacontrol_playlist_add_item( servant->mc, psz_file, exception );    MC_EXCEPT();    return;}static voidimpl_VLC_MediaControl_playlist_clear( impl_POA_VLC_MediaControl * servant,                                      CORBA_Environment * ev ){    mediacontrol_Exception *exception = NULL;      MC_TRY;    mediacontrol_playlist_clear( servant->mc, exception );    MC_EXCEPT();    return;}static VLC_PlaylistSeq *impl_VLC_MediaControl_playlist_get_list( impl_POA_VLC_MediaControl * servant,                                         CORBA_Environment * ev ){    VLC_PlaylistSeq *retval = NULL;    mediacontrol_Exception *exception = NULL;    mediacontrol_PlaylistSeq* p_ps;    int i_index;       MC_TRY;    p_ps = mediacontrol_playlist_get_list( servant->mc, exception );    MC_EXCEPT( retval );    retval = VLC_PlaylistSeq__alloc();    retval->_buffer = VLC_PlaylistSeq_allocbuf( p_ps->size );    retval->_length = p_ps->size;      for( i_index = 0 ; i_index < p_ps->size ; i_index++ )    {        retval->_buffer[i_index] = CORBA_string_dup( p_ps->data[i_index] );    }    CORBA_sequence_set_release( retval, TRUE );      mediacontrol_PlaylistSeq__free( p_ps );    return retval;}VLC_RGBPicture*createRGBPicture( mediacontrol_RGBPicture* p_pic ){    VLC_RGBPicture *retval;      retval = VLC_RGBPicture__alloc();    if( retval )    {        retval->width  = p_pic->width;        retval->height = p_pic->height;        retval->type   = p_pic->type;        retval->date   = p_pic->date;              retval->data._maximum = p_pic->size;        retval->data._length = p_pic->size;        retval->data._buffer = VLC_ByteSeq_allocbuf( p_pic->size );        memcpy( retval->data._buffer, p_pic->data, p_pic->size );        /* CORBA_sequence_set_release( &( retval->data ), FALSE ); */    }    return retval;}static VLC_RGBPicture *impl_VLC_MediaControl_snapshot( impl_POA_VLC_MediaControl * servant,                                const VLC_Position * a_position,                                CORBA_Environment * ev ){    VLC_RGBPicture *retval = NULL;    mediacontrol_RGBPicture* p_pic = NULL;    mediacontrol_Position *p_pos;    mediacontrol_Exception *exception = NULL;    p_pos = corba_position_corba_to_c( a_position );      MC_TRY;    p_pic = mediacontrol_snapshot( servant->mc, p_pos, exception );    MC_EXCEPT( retval );      retval = createRGBPicture( p_pic );    mediacontrol_RGBPicture__free( p_pic );    return retval;}static VLC_RGBPictureSeq *impl_VLC_MediaControl_all_snapshots( impl_POA_VLC_MediaControl * servant,                                     CORBA_Environment * ev ){    VLC_RGBPictureSeq *retval = NULL;    mediacontrol_RGBPicture** p_piclist = NULL;    mediacontrol_RGBPicture** p_tmp = NULL;    mediacontrol_Exception *exception = NULL;    int i_size = 0;    int i_index;      MC_TRY;    p_piclist = mediacontrol_all_snapshots( servant->mc, exception );    MC_EXCEPT( retval );    for( p_tmp = p_piclist ; *p_tmp != NULL ; p_tmp++ )        i_size++;      retval = VLC_RGBPictureSeq__alloc();    retval->_buffer = VLC_RGBPictureSeq_allocbuf( i_size );    retval->_length = i_size;    for( i_index = 0 ; i_index < i_size ; i_index++ )    {        mediacontrol_RGBPicture *p_pic = p_piclist[i_index];        VLC_RGBPicture *p_rgb;              p_rgb = &( retval->_buffer[i_index] );              p_rgb->width  = p_pic->width;        p_rgb->height = p_pic->height;        p_rgb->type   = p_pic->type;        p_rgb->date   = p_pic->date;              p_rgb->data._maximum = p_pic->size;        p_rgb->data._length  = p_pic->size;        p_rgb->data._buffer  = VLC_ByteSeq_allocbuf( p_pic->size );        memcpy( p_rgb->data._buffer, p_pic->data, p_pic->size );        mediacontrol_RGBPicture__free( p_pic );    }      free( p_piclist );    return retval;}static voidimpl_VLC_MediaControl_display_text( impl_POA_VLC_MediaControl * servant,                                    const CORBA_char * message,                                    const VLC_Position * begin,                                    const VLC_Position * end,                                    CORBA_Environment * ev ){    mediacontrol_Position *p_begin = NULL;    mediacontrol_Position *p_end = NULL;    mediacontrol_Exception *exception = NULL;    p_begin = corba_position_corba_to_c( begin );    p_end = corba_position_corba_to_c( end );    MC_TRY;    mediacontrol_display_text( servant->mc, message, p_begin, p_end, exception );    MC_EXCEPT();    free( p_begin );    free( p_end );    return;}static VLC_StreamInformation *impl_VLC_MediaControl_get_stream_information( impl_POA_VLC_MediaControl *                                              servant, CORBA_Environment * ev ){    mediacontrol_Exception *exception = NULL;    mediacontrol_StreamInformation *p_si = NULL;    VLC_StreamInformation *retval = NULL;    MC_TRY;    p_si = mediacontrol_get_stream_information( servant->mc, mediacontrol_MediaTime, exception );    MC_EXCEPT( retval );    retval = VLC_StreamInformation__alloc();    if( ! retval )    {        return NULL;    }    retval->streamstatus = p_si->streamstatus;    retval->url          = CORBA_string_dup( p_si->url );    retval->position     = p_si->position;    retval->length       = p_si->length;      free( p_si->url );    free( p_si );    return retval;}static CORBA_unsigned_shortimpl_VLC_MediaControl_sound_get_volume( impl_POA_VLC_MediaControl * servant,                                        CORBA_Environment * ev ){    CORBA_short retval = 0;    mediacontrol_Exception *exception = NULL;      MC_TRY;    retval = mediacontrol_sound_get_volume( servant->mc, exception );    MC_EXCEPT( retval );    return retval;}static voidimpl_VLC_MediaControl_sound_set_volume( impl_POA_VLC_MediaControl * servant,                                        const CORBA_unsigned_short volume,                                        CORBA_Environment * ev ){    mediacontrol_Exception *exception = NULL;      MC_TRY;    mediacontrol_sound_set_volume( servant->mc, volume, exception );    MC_EXCEPT();}/* ( Real ) end of the CORBA code generated in Mediacontrol-skelimpl.c *//***************************************************************************** * Local prototypes. *****************************************************************************/static int  Open         ( vlc_object_t * );static void Close        ( vlc_object_t * );static void Run          ( intf_thread_t * );/***************************************************************************** * Module descriptor *****************************************************************************/vlc_module_begin();set_category( CAT_INTERFACE );set_subcategory( SUBCAT_INTERFACE_CONTROL );add_category_hint( N_( "Corba control" ), NULL, VLC_FALSE );set_description( _( "corba control module" ) );set_capability( "interface", 10 );add_integer( "corba-reactivity", 5000, NULL, "Internal reactivity factor", "Internal reactivity factor ( gtk timeout is INTF_IDLE_SLEEP / factor )", VLC_TRUE );set_callbacks( Open, Close );vlc_module_end();/***************************************************************************** * intf_Open: initialize and create stuff *****************************************************************************/static int Open( vlc_object_t *p_this ){    intf_thread_t *p_intf = ( intf_thread_t * )p_this;    /* Allocate instance and initialize some members */    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );    if( p_intf->p_sys == NULL )    {        msg_Err( p_intf, "Out of memory" );        return VLC_ENOMEM;    }    /* Initialize the fields of the p_intf struct */    p_intf->pf_run = Run;    p_intf->p_sys->mc = NULL;    p_intf->p_sys->orb = NULL;    p_intf->p_sys->corbaloop = NULL;    return VLC_SUCCESS;}/***************************************************************************** * intf_Close: destroy interface *****************************************************************************/static void Close( vlc_object_t *p_this ){    intf_thread_t *p_intf = ( intf_thread_t * )p_this;    CORBA_Environment*        ev = NULL;    ev = CORBA_exception__alloc();    CORBA_ORB_shutdown( p_intf->p_sys->orb, FALSE, ev );    handle_exception_no_servant( p_intf, "Error in Close" );    /* Destroy structure */    free( p_intf->p_sys );}/*  Function called regularly to handle various tasks( mainly CORBA calls )*/static gboolean Manage( gpointer p_interface ){    intf_thread_t *p_intf = ( intf_thread_t* )p_interface;    CORBA_boolean b_work_pending;    CORBA_Environment* ev;    ev = CORBA_exception__alloc();    /* CORBA */    b_work_pending = CORBA_ORB_work_pending( p_intf->p_sys->orb, ev );    if( ev->_major != CORBA_NO_EXCEPTION )    {        msg_Err( p_intf, "Exception in CORBA events check loop" );        return FALSE;    }      vlc_mutex_lock( &p_intf->change_lock );    if( b_work_pending )        CORBA_ORB_perform_work( p_intf->p_sys->orb, ev );      if( p_intf->b_die )    {        vlc_mutex_unlock( &p_intf->change_lock );        CORBA_ORB_shutdown( p_intf->p_sys->orb, TRUE, ev );        g_main_loop_quit( p_intf->p_sys->corbaloop );        /* Just in case */        return( TRUE );    }    vlc_mutex_unlock( &p_intf->change_lock );    return TRUE;}/***************************************************************************** * Run: main loop ***************************************************************************** * this part of the interface is in a separate thread so that we can call * g_main_loop_run() from within it without annoying the rest of the program. *****************************************************************************/static void Run( intf_thread_t *p_intf ){    CORBA_Environment*        ev = NULL;    PortableServer_POA        root_poa;    PortableServer_POAManager root_poa_manager;    guint                     i_event_source;    CORBA_char*               psz_objref;    impl_POA_VLC_MediaControl *servant = NULL;    VLC_MediaControl          corba_instance;    mediacontrol_Instance     *mc_instance;    mediacontrol_Exception    *exception = NULL;    int i_argc = 1;    char* ppsz_argv[] = { "mc" };    int i_reactivity;    ev = CORBA_exception__alloc();    p_intf->p_sys->orb = CORBA_ORB_init( &i_argc, ppsz_argv, "orbit-local-orb", ev );    /* Should be cleaner this way ( cf       http://www.fifi.org/doc/gnome-dev-doc/html/C/orbitgtk.html ) but it       functions well enough in the ugly way so that I do not bother       cleaning it */    /* p_intf->p_sys->orb = gnome_CORBA_init ( "VLC", NULL, &argc, &argv, 0, NULL, ev ); */    handle_exception_no_servant( p_intf, "Exception during CORBA_ORB_init" );    root_poa = ( PortableServer_POA )CORBA_ORB_resolve_initial_references( p_intf->p_sys->orb, "RootPOA", ev );    handle_exception( "Exception during RootPOA initialization" );    corba_instance = impl_VLC_MediaControl__create( root_poa, ev );    handle_exception( "Exception during MediaControl initialization" );    servant = ( impl_POA_VLC_MediaControl* )PortableServer_POA_reference_to_servant( root_poa, corba_instance, ev );    handle_exception( "Exception during MediaControl access" );    MC_TRY;    mc_instance = mediacontrol_new_from_object((vlc_object_t* )p_intf, exception );    MC_EXCEPT();    p_intf->p_sys->mc = mc_instance;    servant->p_intf = p_intf;    servant->mc = p_intf->p_sys->mc;    psz_objref = CORBA_ORB_object_to_string( p_intf->p_sys->orb, corba_instance, ev );    handle_exception( "Exception during IOR generation" );    msg_Warn( p_intf, "MediaControl IOR :" );    msg_Warn( p_intf, psz_objref );    /* We write the IOR in a file. */    {        FILE* fp;        fp = fopen( VLC_IOR_FILE, "w" );        if( fp == NULL )        {            msg_Err( p_intf, "Cannot write the IOR to %s ( %d ).", VLC_IOR_FILE, errno );        }        else        {            fprintf( fp, "%s", psz_objref );            fclose( fp );            msg_Warn( p_intf, "IOR written to %s", VLC_IOR_FILE );        }    }      root_poa_manager = PortableServer_POA__get_the_POAManager( root_poa, ev );    handle_exception( "Exception during POAManager resolution" );    PortableServer_POAManager_activate( root_poa_manager, ev );    handle_exception( "Exception during POAManager activation" );    msg_Info( p_intf, "corba remote control interface initialized" );    /*    // Tentative de gestion du nommage...    {    CosNaming_NamingContext name_service;    CosNaming_NameComponent name_component[3] = {{"GNOME", "subcontext"},    {"Servers", "subcontext"},    {"vlc", "server"} };    CosNaming_Name name = {3, 3, name_component, CORBA_FALSE};    name_service = CORBA_ORB_resolve_initial_references( p_intf->p_sys->orb,    "NameService",    ev );    handle_exception( "Error: could not get name service: %s\n",    CORBA_exception_id( ev ) );    msg_Warn( p_intf, "Name service OK" );    CosNaming_NamingContext_bind( name_service, &name, p_intf->p_sys->mc, ev );    handle_exception( "Error: could not register object: %s\n",    CORBA_exception_id( ev ) );    }    */    /* The time factor should be 1/1000 but it is a little too       slow. Make it 1/10000 */    i_reactivity = config_GetInt( p_intf, "corba-reactivity" );    i_event_source = g_timeout_add( INTF_IDLE_SLEEP / i_reactivity, Manage, p_intf );    p_intf->p_sys->corbaloop = g_main_loop_new( NULL, FALSE );    g_main_loop_run( p_intf->p_sys->corbaloop );    /* Cleaning */    g_source_remove( i_event_source );    unlink( VLC_IOR_FILE );    /* Make sure we exit ( In case other interfaces have been spawned ) */    mediacontrol_exit( p_intf->p_sys->mc );    return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -