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

📄 eyetvplugin.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
    }    return result;}/* called if a device is removed */static long VLCEyeTVPluginDeviceRemoved(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID){    printf("VLC media player Plug-In: DeviceRemoved\n");        long result = 0;            --i_deviceCount;    if( 0 == i_deviceCount )    {                        /* notify a potential VLC instance about the removal */        CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),                                              CFSTR("DeviceRemoved"),                                               CFSTR(VLC_NOTIFICATION_OBJECT),                                               /*userInfo*/ NULL,                                               TRUE );    }    if( (i_vlcSock != -1) && (deviceID == globals->activeDeviceID) )    {        close(i_vlcSock);        i_vlcSock = -1;        printf( "data sending switched off\n" );    }        return result;}/* This function is called, whenever packets are received by EyeTV. For reasons of performance, * the data is the original data, not a copy. That means, EyeTV waits until this method is  * finished. Therefore all in this method should be as fast as possible. */static long VLCEyeTVPluginPacketsArrived(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID, long **packets, long packetsCount){    if( globals )     {        /* check if data connection is active */        if( i_vlcSock != -1 )        {            if( deviceID == globals->activeDeviceID )             {                long pidCount = globals->activePIDsCount;                if( pidCount )                {                    uint8_t packetBuffer[sizeof(TransportStreamPacket)*20];                    int packetBufferSize = 0;                    while( packetsCount )                    {                        /* apply PID filtering, only PIDs in active service for device are sent through */                        long pid = ntohl(**packets)>>8 & 0x1FFFL;                        /* ignore NULL packets */                        if( 0x1FFFL != pid )                        {                            long i;                            for( i=0; i<pidCount; ++i )                            {                                if( globals->activePIDs[i].pid == pid )                                {                                    if( packetBufferSize <= (sizeof(packetBuffer)-sizeof(TransportStreamPacket)) )                                    {                                        /* copy packet in our buffer */                                        memcpy(packetBuffer+packetBufferSize, *packets, sizeof(TransportStreamPacket));                                        packetBufferSize += sizeof(TransportStreamPacket);                                    }                                    else                                    {                                        /* flush buffer to VLC */                                        ssize_t sent = write(i_vlcSock, packetBuffer, packetBufferSize);                                        if( sent != packetBufferSize )                                        {                                            if( sent == -1 )                                                printf("data sending failed (errno=%d)\n", errno);                                            else                                                printf("data sending incomplete (sent=%d)\n", sent);                                            close(i_vlcSock);                                            i_vlcSock = -1;                                            return 0;                                        }                                        packetBufferSize = 0;                                    }                                    if( i > 0 )                                    {                                       /* if we assume that consecutive packets would have the same PID in most cases,                                          it would therefore speed up filtering to reorder activePIDs list based on pid                                          occurrences */                                        EyeTVPluginPIDInfo swap = globals->activePIDs[i];                                        do                                        {                                            register int c = i--;                                            globals->activePIDs[c] = globals->activePIDs[i];                                        }                                        while( i );                                        globals->activePIDs[i] = swap;                                    }                                    if( pid && globals->activePIDs[0].pidType != kEyeTVPIDType_PMT )                                    {                                        /* to save on CPU, prevent EyeTV from mirroring that program by blocking video & audio packets                                           by changing all packets but PAT and PMT to NULL PID */#if defined(WORDS_BIGENDIAN)                                        **packets |= 0x001FFF00L;#else                                        **packets |= 0x00FFF800L;#endif                                    }                                    /* done filtering on this packet, move on to next packet */                                    break;                                }                            }                        }                        --packetsCount;                        ++packets;                    }                    if( packetBufferSize )                    {                        /* flush buffer to VLC */                        ssize_t sent = write(i_vlcSock, packetBuffer, packetBufferSize);                        if( sent != packetBufferSize )                        {                            if( sent == -1 )                                printf("data sending failed (errno=%d)\n", errno);                            else                                printf("data sending incomplete (sent=%d)\n", sent);                            close(i_vlcSock);                            i_vlcSock = -1;                            return 0;                        }                    }                }            }        }    }    return 0;}/*  VLCEyeTVPluginServiceChanged, * *  - *globals      : The plug-in Globals *  - deviceID      : Identifies the active Device *   - headendID        : The HeadendID, for e300 it's the orbital position of the satelite in  *                    tenth degrees east *   - transponderID : The Frequency in kHz *   - serviceID        : original ServiceID from the DVB-Stream (e300, e400) *  - pidList       : List of active PIDs    * *  Whenever a service changes, this function is called. Service-related plug-in data should be updated here. */static long VLCEyeTVPluginServiceChanged(VLCEyeTVPluginGlobals_t *globals,                                             EyeTVPluginDeviceID deviceID,                                             long headendID,                                             long transponderID,                                             long serviceID,                                             EyeTVPluginPIDInfo *pidList,                                             long pidsCount){    long result = 0;    int i;        printf("\nVLC media player Plug-In: ServiceChanged:\n");    printf(  "=====================================\n");        if( globals )     {        printf("DeviceID: %ld, ", deviceID);        printf("HeadendID: %ld, ", headendID);        printf("TransponderID: %ld, ", transponderID);        printf("ServiceID: %ld\n\n", serviceID);                globals->activeDeviceID = deviceID;        globals->activePIDsCount = pidsCount;        /* need active PIDs for packet filtering */        for( i = 0; i < pidsCount; i++ )        {            globals->activePIDs[i] = pidList[i];            printf("Active PID: %ld, type: %ld\n", pidList[i].pid, pidList[i].pidType);        }    }    printf(  "=====================================\n");        /* notify a potential VLC instance about the service change */    CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),                                          CFSTR("ServiceChanged"),                                           CFSTR(VLC_NOTIFICATION_OBJECT),                                           /*userInfo*/ NULL,                                           TRUE );        return result;}#pragma mark -/* EyeTVPluginDispatcher, * *  - selector : See 'EyeTVPluginDefs.h' *  - *refCon :  The RefCon to the plug-in-related Data *  - deviceID : Identifies the Device *  - params : Parameters for functioncall * * This function is a part of the interface for the communication with EyeTV. If something happens, * EyeTV thinks, we should know of, it calls this function with the corresponding selector. */#pragma export onlong EyeTVPluginDispatcher( EyeTVPluginParams* params ){    long result = 0;    switch( params->selector )     {        case kEyeTVPluginSelector_Initialize:            result = VLCEyeTVPluginInitialize((VLCEyeTVPluginGlobals_t**)params->refCon,                                     params->initialize.apiVersion, params->initialize.callback);            break;                    case kEyeTVPluginSelector_Terminate:            result = VLCEyeTVPluginTerminate((VLCEyeTVPluginGlobals_t*)params->refCon);            break;        case kEyeTVPluginSelector_GetInfo:            result = VLCEyeTVPluginGetInformation((VLCEyeTVPluginGlobals_t*)params->refCon,                                     params->info.pluginAPIVersion, params->info.pluginName, params->info.description);            break;        case kEyeTVPluginSelector_DeviceAdded:            result = VLCEyeTVPluginDeviceAdded((VLCEyeTVPluginGlobals_t*)params->refCon,                                     params->deviceID, params->deviceAdded.deviceType);            break;                case kEyeTVPluginSelector_DeviceRemoved:            result = VLCEyeTVPluginDeviceRemoved((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID);            break;        case kEyeTVPluginSelector_PacketsArrived:            result = VLCEyeTVPluginPacketsArrived((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID,                                     params->packetsArrived.packets, params->packetsArrived.packetCount);            break;        case kEyeTVPluginSelector_ServiceChanged:            result = VLCEyeTVPluginServiceChanged((VLCEyeTVPluginGlobals_t*)params->refCon,                                     params->deviceID, params->serviceChanged.headendID,                                     params->serviceChanged.transponderID, params->serviceChanged.serviceID,                                     params->serviceChanged.pidList, params->serviceChanged.pidCount);            break;    }    return result;}

⌨️ 快捷键说明

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