Changeset 36868ee9e839aebe9dca54ca7019bde6312f598a

Show
Ignore:
Timestamp:
01/15/08 00:18:13 (8 months ago)
Author:
Damien Fouilleul <damienf@videolan.org>
git-committer:
Damien Fouilleul <damienf@videolan.org> 1200352693 +0000
git-parent:

[5266ede11c5f1a98e170b23eae90c194368cc08b]

git-author:
Damien Fouilleul <damienf@videolan.org> 1200352693 +0000
Message:

eyetv: latest version of EyeTV capture plugin, needs lotta testing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • extras/MacOSX/eyetvplugin/eyetvplugin.c

    r10649df r36868ee  
    2424#include "eyetvplugin.h" 
    2525 
    26 #define MAX_PIDS            256 
    27 #define MAX_ACTIVE_PIDS     256 
    28 #define MAX_DEVICES         16 
     26#include <sys/types.h> 
     27#include <sys/socket.h> 
     28#include <sys/un.h> 
     29#include <unistd.h> 
     30 
     31#define MAX_PIDS            256 
     32#define MAX_ACTIVE_PIDS     256 
     33#define MAX_DEVICES         16 
    2934#define VLC_NOTIFICATION_OBJECT "VLCEyeTVSupport" 
    3035 
     
    3237#pragma pack(1) 
    3338 
     39typedef struct 
     40{ 
     41    uint32_t    sync_byte : 8, 
     42                transport_error_indicator : 1, 
     43                payload_unit_start_indicator : 1, 
     44                transport_priority : 1, 
     45                PID : 13, 
     46                transport_scrambling_control : 2, 
     47                adaptation_field_control : 2, 
     48                continuity_counter : 4; 
     49} TransportStreamHeader; 
    3450 
    3551/* Structure for TS-Packets */ 
    3652typedef struct  
    3753{ 
    38     unsigned long           sync_byte : 8, 
    39                             transport_error_indicator : 1, 
    40                             payload_unit_start_indicator : 1, 
    41                             transport_priority : 1, 
    42                             PID : 13, 
    43                             transport_scrambling_control : 2, 
    44                             adaptation_field_control : 2, 
    45                             continuity_counter : 4; 
    46  
    47     unsigned char           data[188-4]; 
     54    TransportStreamHeader   header; 
     55    uint8_t                 payload[184]; 
    4856 
    4957} TransportStreamPacket; 
    5058 
    5159#pragma pop 
    52  
    53  
    54 /* Structure to hold Information on devices */ 
    55 typedef struct 
    56 { 
    57     EyeTVPluginDeviceID         deviceID; 
    58     EyeTVPluginDeviceType       deviceType; 
    59  
    60     long                        headendID; 
    61     long                        transponderID; 
    62     long                        serviceID; 
    63  
    64     long                        pidsCount; 
    65     long                        pids[MAX_PIDS]; 
    66  
    67     EyeTVPluginPIDInfo          activePIDs[MAX_ACTIVE_PIDS]; 
    68     long                        activePIDsCount; 
    69  
    70 } DeviceInfo; 
    7160 
    7261 
     
    7463typedef struct  
    7564{ 
    76     EyeTVPluginCallbackProc         callback; 
    77     long                            deviceCount; 
    78     DeviceInfo                      devices[MAX_DEVICES]; 
    79     long long                       packetCount; 
    80  
     65    EyeTVPluginCallbackProc     callback; 
     66    /* Structure to hold current active service */ 
     67    EyeTVPluginDeviceID         activeDeviceID; 
     68    long                        activePIDsCount;  
     69    EyeTVPluginPIDInfo          activePIDs[MAX_ACTIVE_PIDS]; 
     70    long                        seenPIDs[MAX_ACTIVE_PIDS]; 
    8171} VLCEyeTVPluginGlobals_t; 
    8272 
    83 /* 2nd structure to store our own global data which isn't shared with EyeTV 
    84  * a bit empty at the moment, but it will get larger as development progresses */ 
    85 typedef struct 
    86 
    87     int                     i_deviceCount; 
    88     CFMessagePortRef        messagePortToVLC; 
    89     bool                    b_msgPortOpen; 
    90 } VLCEyeTVPluginOwnGlobals_t; 
    91  
    92 VLCEyeTVPluginOwnGlobals_t *nativeGlobals; 
    93  
    94  
    95 /* return the DeviceInfo with ID deviceID */ 
    96 static DeviceInfo *GetDeviceInfo(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID) 
    97 
    98     int i; 
    99      
    100     if( globals )  
    101     { 
    102         for( i=0; i<globals->deviceCount; i++)  
    103         { 
    104             if( globals->devices[i].deviceID == deviceID )  
    105             { 
    106                 return &globals->devices[i]; 
    107             } 
    108         } 
    109     } 
    110  
    111     return NULL; 
    112 
     73static int i_deviceCount; 
     74static int vlcSock; 
    11375 
    11476#pragma mark - 
     
    11779static long VLCEyeTVPluginInitialize(VLCEyeTVPluginGlobals_t** globals, long apiVersion, EyeTVPluginCallbackProc callback) 
    11880{ 
    119    printf("VLC media player Plug-In: Initialize\n"); 
    120    long result = 0; 
     81    printf("VLC media player Plug-In: Initialize\n"); 
     82    long result = 0; 
    12183     
    12284    /* init our own storage */ 
    123     extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals
    124     nativeGlobals = malloc( sizeof( VLCEyeTVPluginOwnGlobals_t ) )
     85    i_deviceCount = 0
     86    vlcSock = -1
    12587     
    12688    /* notify a potential VLC instance about our initialisation */ 
     
    138100                                     CFSTR(VLC_NOTIFICATION_OBJECT),  
    139101                                     CFNotificationSuspensionBehaviorDeliverImmediately ); 
    140      
    141    *globals = (VLCEyeTVPluginGlobals_t *) calloc(1, sizeof( VLCEyeTVPluginGlobals_t ) ); 
    142    ( *globals )->callback = callback; 
    143          
    144    return result; 
     102     
     103    *globals = (VLCEyeTVPluginGlobals_t *) calloc(1, sizeof( VLCEyeTVPluginGlobals_t ) ); 
     104    ( *globals )->callback = callback; 
     105         
     106    return result; 
    145107} 
    146108 
     
    148110static long VLCEyeTVPluginTerminate(VLCEyeTVPluginGlobals_t *globals) 
    149111{ 
    150     extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals; 
    151      
    152     printf("VLC media player Plug-In: Terminate\n"); 
    153      
    154     long result = 0; 
    155      
     112    long result = 0; 
     113     
     114    printf("VLC media player Plug-In: Terminate\n"); 
     115     
    156116    /* notify a potential VLC instance about our termination */ 
    157117    CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter (), 
     
    165125                                             (void *)VLCEyeTVPluginGlobalNotificationReceived ); 
    166126     
    167     /* invalidate and free msg port */ 
    168     if( nativeGlobals->messagePortToVLC ) 
    169     { 
    170         CFMessagePortInvalidate( nativeGlobals->messagePortToVLC ); 
    171         free( nativeGlobals->messagePortToVLC ); 
    172         printf( "msgport invalidated and freed\n" ); 
    173     } 
    174     else 
    175         printf( "no msgport to free\n" ); 
    176      
    177     if( globals )  
    178     { 
    179         free( globals ); 
    180     } 
    181  
    182     if( nativeGlobals ) 
    183         free( nativeGlobals ); 
    184      
    185     return result; 
     127    /* close data connection */ 
     128    if( vlcSock != -1 ) 
     129    { 
     130        close( vlcSock ); 
     131        vlcSock = -1; 
     132    } 
     133     
     134    if( globals )  
     135    { 
     136        long i; 
     137        for( i=0; i<globals->activePIDsCount; ++i ) 
     138        { 
     139            printf("activePID: %ld, count=%ld\n", globals->activePIDs[i].pid, globals->seenPIDs[i] ); 
     140        } 
     141        free( globals ); 
     142    } 
     143 
     144    return result; 
    186145} 
    187146 
     
    189148static long VLCEyeTVPluginGetInformation(VLCEyeTVPluginGlobals_t *globals, long* outAPIVersion, char* outName, char *outDescription) 
    190149{ 
    191     printf("VLC media player Plug-In: GetInfo\n"); 
    192     long result = 0; 
    193      
    194     if( globals )  
    195     { 
    196         if( outAPIVersion ) 
    197         { 
    198             *outAPIVersion = EYETV_PLUGIN_API_VERSION; 
    199         } 
    200          
    201         if( outName ) 
    202         { 
    203             char* name = "VLC media player Plug-In"; 
    204             strcpy( &outName[0], name); 
    205         } 
    206          
    207         if( outDescription ) 
    208         { 
    209             char* desc = "This Plug-In connects EyeTV to the VLC media player for streaming purposes."; 
    210             strcpy( &outDescription[0], desc); 
    211         } 
    212     } 
    213      
    214     return result; 
     150    printf("VLC media player Plug-In: GetInfo\n"); 
     151    long result = 0; 
     152     
     153    if( globals )  
     154    { 
     155        if( outAPIVersion ) 
     156        { 
     157            *outAPIVersion = EYETV_PLUGIN_API_VERSION; 
     158        } 
     159         
     160        if( outName ) 
     161        { 
     162            strcpy( outName, "VLC media player Plug-In"); 
     163        } 
     164         
     165        if( outDescription ) 
     166        { 
     167            strcpy( outDescription, "This Plug-In connects EyeTV to the VLC media player for streaming purposes."); 
     168        } 
     169    } 
     170     
     171    return result; 
    215172} 
    216173 
     
    222179                                              CFDictionaryRef userInfo ) 
    223180{ 
    224     CFIndex maxlen; 
    225     char *theName, *theObject; 
    226     extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals; 
    227  
    228     maxlen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( name ), 
    229                                                 kCFStringEncodingUTF8) + 1; 
    230     theName = malloc(maxlen); 
    231     CFStringGetCString( name,  
    232                         theName,  
    233                         maxlen, 
    234                         kCFStringEncodingUTF8); 
    235      
    236     maxlen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( name ), 
    237                                                 kCFStringEncodingUTF8) + 1; 
    238     theObject = malloc(maxlen); 
    239     CFStringGetCString( object,  
    240                         theObject,  
    241                         maxlen, 
    242                         kCFStringEncodingUTF8); 
    243     printf( "notication received with name: %s and object: %s\n", theName, theObject ); 
    244      
    245181    /* when VLC launches after us, we need to inform it about our existance and the current state of available devices */ 
    246182    if( CFStringCompare( name, CFSTR( "VLCOSXGUIInit" ), 0) == kCFCompareEqualTo ) 
     
    252188                                              /*userInfo*/ NULL,  
    253189                                              TRUE ); 
    254         if( nativeGlobals && ( nativeGlobals->i_deviceCount > 0 )
     190        if( i_deviceCount > 0
    255191        { 
    256192            /* at least one device is apparently connected */ 
     
    266202    if( CFStringCompare( name, CFSTR( "VLCAccessStartDataSending" ), 0) == kCFCompareEqualTo ) 
    267203    { 
    268         nativeGlobals->messagePortToVLC = CFMessagePortCreateRemote( kCFAllocatorDefault, 
    269                                                                      CFSTR("VLCEyeTVMsgPort") ); 
    270         if( nativeGlobals->messagePortToVLC == NULL ) 
    271             printf( "getting messagePortToVLC failed!\n" ); 
    272         else 
    273         { 
    274             nativeGlobals->b_msgPortOpen = TRUE; 
    275             printf( "msg port opened / data sending switched on\n" ); 
     204        if( vlcSock == -1 ) 
     205        { 
     206            int peerSock; 
     207          
     208            /* set-up data socket */ 
     209            peerSock = socket(AF_UNIX, SOCK_STREAM, 0); 
     210            if( peerSock != -1 ) 
     211            { 
     212                struct sockaddr_un peerAddr; 
     213                /* set-up connection address */ 
     214                memset(&peerAddr, 0, sizeof(peerAddr)); 
     215                peerAddr.sun_family = AF_UNIX; 
     216                strncpy(peerAddr.sun_path, "/tmp/.vlc-eyetv-bridge", sizeof(peerAddr.sun_path)-1); 
     217                 
     218                /* connect */ 
     219                printf("data connect in progess...\n"); 
     220                if( connect(peerSock, (struct sockaddr *)&peerAddr, sizeof(struct sockaddr_un)) != -1 ) 
     221                { 
     222                    printf("data sending switched on\n"); 
     223                    vlcSock = peerSock; 
     224                } 
     225                else 
     226                    printf("connect data socket failed (errno=%d)\n", errno ); 
     227            } 
     228            else 
     229                printf("create data socket failed (errno=%d)\n", errno ); 
    276230        } 
    277231    } 
     
    280234    if( CFStringCompare( name, CFSTR( "VLCAccessStopDataSending" ), 0) == kCFCompareEqualTo ) 
    281235    { 
    282         nativeGlobals->b_msgPortOpen = FALSE; 
    283         printf( "data sending switched off\n" ); 
     236        if( vlcSock != -1 ) 
     237        { 
     238            close( vlcSock ); 
     239            vlcSock = -1; 
     240            printf( "data sending switched off\n" ); 
     241        } 
    284242    } 
    285243} 
     
    288246static long VLCEyeTVPluginDeviceAdded(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID, EyeTVPluginDeviceType deviceType) 
    289247{ 
    290     printf("VLC media player Plug-In: Device with type %i and ID %i added\n", (int)deviceType, (int)deviceID); 
    291      
    292     long result = 0; 
    293     DeviceInfo *deviceInfo; 
    294     extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals; 
    295      
    296      
    297     if( globals )  
    298     { 
    299         if( globals->deviceCount < MAX_DEVICES )  
    300         { 
    301             deviceInfo = &( globals->devices[globals->deviceCount] ); 
    302             memset(deviceInfo, 0, sizeof(DeviceInfo)); 
    303              
    304             deviceInfo->deviceID = deviceID; 
    305             deviceInfo->deviceType = deviceType; 
    306  
    307             globals->deviceCount++; 
    308  
    309             if( nativeGlobals ) 
    310                 nativeGlobals->i_deviceCount = globals->deviceCount; 
    311  
     248    printf("VLC media player Plug-In: Device with type %i and ID %i added\n", (int)deviceType, (int)deviceID); 
     249     
     250    long result = 0; 
     251     
     252    if( globals )  
     253    { 
     254        ++i_deviceCount; 
     255        if( 1 == i_deviceCount ) 
     256        {                 
    312257            /* notify a potential VLC instance about the addition */ 
    313258            CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(), 
     
    316261                                                  /*userInfo*/ NULL,  
    317262                                                  TRUE ); 
    318         } 
    319     } 
    320  
    321     return result; 
     263        } 
     264    } 
     265    return result; 
    322266} 
    323267 
     
    325269static long VLCEyeTVPluginDeviceRemoved(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID) 
    326270{ 
    327     printf("VLC media player Plug-In: DeviceRemoved\n"); 
    328      
    329     extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals; 
    330     long result = 0; 
    331     int i; 
    332      
    333     if( globals )  
    334     { 
    335         for( i = 0; i < globals->deviceCount; i++ ) 
    336         { 
    337             if ( globals->devices[i].deviceID == deviceID )  
    338             { 
    339                 globals->deviceCount--; 
    340  
    341                 if( i<globals->deviceCount ) 
    342                 { 
    343                     globals->devices[i] = globals->devices[globals->deviceCount]; 
    344                 } 
    345                  
    346                 if( nativeGlobals ) 
    347                     nativeGlobals->i_deviceCount = globals->deviceCount; 
    348                  
    349                 /* notify a potential VLC instance about the removal */ 
    350                 CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(), 
    351                                                       CFSTR("DeviceRemoved"),  
    352                                                       CFSTR(VLC_NOTIFICATION_OBJECT),  
    353                                                       /*userInfo*/ NULL,  
    354                                                       TRUE ); 
    355             } 
    356         } 
    357     } 
    358      
    359     return result; 
     271    printf("VLC media player Plug-In: DeviceRemoved\n"); 
     272     
     273    long result = 0; 
     274         
     275    --i_deviceCount; 
     276    if( 0 == i_deviceCount ) 
     277    {                 
     278        /* notify a potential VLC instance about the removal */ 
     279        CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(), 
     280                                              CFSTR("DeviceRemoved"),  
     281                                              CFSTR(VLC_NOTIFICATION_OBJECT),  
     282                                              /*userInfo*/ NULL,  
     283                                              TRUE ); 
     284    } 
     285    if( (vlcSock != -1) && (deviceID == globals->activeDeviceID) ) 
     286    { 
     287        close(vlcSock); 
     288        vlcSock = -1; 
     289        printf( "data sending switched off\n" ); 
     290    } 
     291     
     292    return result; 
    360293} 
    361294 
     
    363296 * the data is the original data, not a copy. That means, EyeTV waits until this method is  
    364297 * finished. Therefore all in this method should be as fast as possible. */ 
    365 int i=0; 
    366298static long VLCEyeTVPluginPacketsArrived(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID, long **packets, long packetsCount) 
    367299{ 
    368     long                                result = 0; 
    369     int                                 i, j, isNewPID; 
    370     TransportStreamPacket               *packet; 
    371     extern VLCEyeTVPluginOwnGlobals_t   *nativeGlobals; 
    372     SInt32                              i_returnValue; 
    373     CFMutableDataRef                    theMutableRef; 
    374     uint8_t                             *p_bufferForSending = malloc(4); 
    375     bool                                b_nonSendData; 
    376     int                                 i_lastSentPacket; 
    377      
    378     if( globals && nativeGlobals )  
    379     { 
    380         DeviceInfo *deviceInfo = GetDeviceInfo(globals, deviceID); 
    381  
    382         if( deviceInfo )  
    383         { 
    384             /* alloc the buffer if wanted */ 
    385             if( nativeGlobals->b_msgPortOpen == TRUE ) 
    386                 theMutableRef = CFDataCreateMutable( kCFAllocatorDefault, (188) ); 
    387              
    388             for( i = 0; i < packetsCount; i++ )  
    389             { 
    390                 packet = ( TransportStreamPacket* )packets[i]; 
    391                 isNewPID = 1; 
    392                  
    393                 /* search for PID */ 
    394                 for( j = 0; j < deviceInfo->pidsCount; j++ )  
    395                 { 
    396                     if( packet->PID == deviceInfo->pids[j] )  
    397                     { 
    398                         isNewPID = 0; 
    399                         break; 
    400                     } 
    401                 } 
    402                  
    403                 /* add new PIDs to the DeviceInfo */ 
    404                 if( isNewPID )  
    405                 { 
    406                     printf ("VLC media player Plug-In: SamplePacketsArrived, newPID = %6d\n", packet->PID); 
    407                      
    408                     if( deviceInfo->pidsCount < MAX_PIDS )  
    409                     { 
    410                         deviceInfo->pids[deviceInfo->pidsCount++] = packet->PID; 
    411                     } 
    412                 } 
    413                 else 
     300    if( globals )  
     301    { 
     302        /* check if data connection is active */ 
     303        if( vlcSock != -1 ) 
     304        { 
     305            if( deviceID == globals->activeDeviceID )  
     306            { 
     307                long pidCount = globals->activePIDsCount; 
     308                if( pidCount ) 
    414309                { 
    415                     /* forward data to VLC if wanted */ 
    416                     /* FIXME: we only receive ARD for now */ 
    417                     if( nativeGlobals->b_msgPortOpen == TRUE && ( 
    418                         packet->PID == 1401 || 
    419                         packet->PID == 1402 || 
    420                         packet->PID == 1400 || 
    421                         packet->PID == 1404 || 
    422                         packet->PID == 3070 || 
    423                         packet->PID == 3072 || 
    424                         packet->PID == 3074 || 
    425                         packet->PID == 5074 || 
    426                         packet->PID == 0 || 
    427                         packet->PID == 17 || 
    428                         packet->PID == 19 || 
    429                         packet->PID == 20 ) ) 
     310                    while( packetsCount ) 
    430311                    { 
    431                         /* in a good world, this wouldn't be necessary */ 
    432                         if( theMutableRef == NULL ) 
    433                             theMutableRef = CFDataCreateMutable( kCFAllocatorDefault, (188) ); 
    434                              
    435                         /* collect data to send larger packets */ 
    436                          
    437                         /* enlarge buffer if necessary */ 
    438                         if( i > 0 ) 
    439                             CFDataIncreaseLength( theMutableRef, 188 ); 
    440                          
    441                         /* add missing header */ 
    442                         memcpy( p_bufferForSending, packet, 4 ); 
    443                         CFDataAppendBytes( theMutableRef, p_bufferForSending, sizeof(p_bufferForSending) ); 
    444  
    445                         free( p_bufferForSending ); 
    446                         p_bufferForSending = malloc(4); 
    447                          
    448                         /* add payload */ 
    449                         CFDataAppendBytes( theMutableRef, packet->data, sizeof(packet->data) ); 
    450                          
    451                         b_nonSendData = TRUE; 
    452                          
     312                        /* apply PID filtering, only PIDs in active service for device are sent through */ 
     313                        long pid = (ntohl(**packets) & 0x001FFF00L)>>8; 
     314                        long i; 
     315                        for( i=0; i<pidCount; ++i ) 
     316                        { 
     317                            if( globals->activePIDs[i].pid == pid ) 
     318                            { 
     319                                ssize_t sent = write(vlcSock, *packets, sizeof(TransportStreamPacket)); 
     320                                if( sent != sizeof(TransportStreamPacket) ) 
     321                                { 
     322                                    if( sent == -1 ) 
     323                                        printf("data sending failed (errno=%d)\n", errno); 
     324                                    else 
     325                                        printf("data sending incomplete (sent=%d)\n", sent); 
     326                                    close(vlcSock); 
     327                                    vlcSock = -1; 
     328                                    return 0; 
     329                                } 
     330                                ++(globals->seenPIDs[i]); 
     331#if 0 
     332                                if( i > 0 ) 
     333                                { 
     334                                   /* if we assume that consecutive packets should have the same PID, it would therefore 
     335                                      speed up filtering to reorder activePIDs list based on pid occurrences */ 
     336                                    EyeTVPluginPIDInfo swap = globals->activePIDs[i]; 
     337                                    memmove(globals->activePIDs+1, globals->activePIDs, sizeof(EyeTVPluginPIDInfo)*i); 
     338                                    globals->activePIDs[0] = swap; 
     339                                } 
     340 
     341                                if( pid && filterPidInfo.pidType != kEyeTVPIDType_PMT ) 
     342                                { 
     343                                    /* to save on CPU, prevent EyeTV from mirroring that program by blocking video & audio packets 
     344                                       by changing PID to NULL PID */ 
     345#if defined(WORDS_BIGENDIAN) 
     346                                    **packets |= 0x001FFF00L; 
     347#else 
     348                                    **packets |= 0x00FFF800L; 
     349#endif 
     350                                } 
     351#endif 
     352                                /* done filtering on this packet, move on to next packet */ 
     353                                break; 
     354                            } 
     355                        } 
     356                        if( i == pidCount ) 
     357                            printf("unexpected PID %ld\n", pid); 
    453358                    } 
    454                 } 
    455                  
    456                 globals->packetCount++; 
    457                  
    458                 if( globals->packetCount%10000 == 0 )  
    459                     printf("->  %lld Packets received so far...\n",globals->packetCount); 
    460             } 
    461  
    462             if( nativeGlobals->b_msgPortOpen == TRUE ) 
    463             { 
    464                 printf( "sending %i bytes of data\n", CFDataGetLength( theMutableRef ) ); 
    465                 i_returnValue = CFMessagePortSendRequest( nativeGlobals->messagePortToVLC, 
    466                                                           /* arbitrary int val */ globals->packetCount, 
    467                                                           /* the data */ theMutableRef, 
    468                                                           /* no timeout for sending */ 0, 
    469                                                           /* no timeout for resp */ 0, 
    470                                                           /* no resp. wanted */ NULL, 
    471                                                           NULL ); 
    472                 b_nonSendData = FALSE; 
    473                 i_lastSentPacket = globals->packetCount; 
    474                 if( i_returnValue == kCFMessagePortSendTimeout ) 
    475                     printf( "time out while sending\n" ); 
    476                 else if( i_returnValue == kCFMessagePortReceiveTimeout ) 
    477                     printf( "time out while waiting for resp\n" ); 
    478                 else if( i_returnValue == kCFMessagePortIsInvalid ) 
    479                 { 
    480                     /* suppress any further attemps */  
    481                     printf( "message port is invalid!\n" ); 
    482                     nativeGlobals->b_msgPortOpen = FALSE; 
    483                 } 
    484                 else if( i_returnValue == kCFMessagePortTransportError )  
    485                     printf( "transport error while sending!\n" ); 
    486                 else 
    487                 { 
    488                     //printf( "success, freeing resources\n" ); 
    489                     free( theMutableRef ); 
    490                     theMutableRef = CFDataCreateMutable( kCFAllocatorDefault, (188) ); 
     359                    --packetsCount; 
     360                    ++packets; 
    491361                } 
    492362            } 
    493  
    494         } 
    495     } 
    496     else 
    497         printf( "warning: either globals or nativeGlobals are NIL in VLCEyeTVPluginPacketsArrived" ); 
    498  
    499     /* clean up before leaving function */ 
    500     //if( nativeGlobals->b_msgPortOpen == TRUE ) 
    501      //   free( theMutableRef ); 
    502      
    503     free( p_bufferForSending ); 
    504      
    505     return result; 
    506 
    507  
    508 /*  VLCEyeTVPluginServiceChanged, 
     363        } 
     364    } 
     365    return 0; 
     366
     367 
     368/*  VLCEyeTVPluginServiceChanged, 
    509369 * 
    510  * - *globals      : The plug-in Globals 
    511  * - deviceID      : Identifies the active Device 
    512  *   - headendID       : The HeadendID, for e300 it's the orbital position of the satelite in  
    513  *                   tenth degrees east 
     370 *  - *globals      : The plug-in Globals 
     371 *  - deviceID      : Identifies the active Device 
     372 *   - headendID        : The HeadendID, for e300 it's the orbital position of the satelite in  
     373 *                    tenth degrees east 
    514374 *   - transponderID : The Frequency in kHz 
    515  *   - serviceID       : original ServiceID from the DVB-Stream (e300, e400) 
    516  * - pidList       : List of active PIDs    
     375 *   - serviceID        : original ServiceID from the DVB-Stream (e300, e400) 
     376 *  - pidList       : List of active PIDs    
    517377 * 
    518  * Whenever a service changes, this function is called. Service-related plug-in data should be updated here. 
     378 *  Whenever a service changes, this function is called. Service-related plug-in data should be updated here. 
    519379 */ 
    520380static long VLCEyeTVPluginServiceChanged(VLCEyeTVPluginGlobals_t *globals,  
    521                                             EyeTVPluginDeviceID deviceID,  
    522                                             long headendID,  
    523                                             long transponderID,  
    524                                             long serviceID,  
    525                                             EyeTVPluginPIDInfo *pidList,  
    526                                             long pidsCount) 
    527 
    528     long result = 0; 
    529     int i; 
    530      
    531     printf("\nVLC media player Plug-In: ServiceChanged:\n"); 
    532     printf(  "=====================================\n"); 
    533      
    534     if( globals )  
    535     { 
    536         DeviceInfo *deviceInfo = GetDeviceInfo( globals, deviceID ); 
    537         if( deviceInfo )  
    538         { 
    539             deviceInfo->headendID = headendID; 
    540             printf("HeadendID: %ld, ", headendID); 
    541              
    542             deviceInfo->transponderID = transponderID; 
    543             printf("TransponderID: %ld, ", transponderID); 
    544              
    545             deviceInfo->serviceID = serviceID; 
    546             printf("ServiceID: %ld\n\n", serviceID); 
    547              
    548             deviceInfo->activePIDsCount = pidsCount; 
    549  
    550             for( i = 0; i < pidsCount; i++ ) 
    551             { 
    552                 deviceInfo->activePIDs[i] = pidList[i]; 
    553                 printf("Active PID: %ld, type: %ld\n", pidList[i].pid, pidList[i].pidType); 
    554             } 
    555  
    556             deviceInfo->pidsCount = 0; 
    557              
    558         } 
    559     } 
    560     printf(  "=====================================\n"); 
    561      
     381                                            EyeTVPluginDeviceID deviceID,  
     382                                            long headendID,  
     383                                            long transponderID,  
     384                                            long serviceID,  
     385                                            EyeTVPluginPIDInfo *pidList,  
     386                                            long pidsCount) 
     387
     388    long result = 0; 
     389    int i; 
     390     
     391    printf("\nVLC media player Plug-In: ServiceChanged:\n"); 
     392    printf(  "=====================================\n"); 
     393     
     394    if( globals )  
     395    { 
     396        printf("DeviceID: %ld, ", deviceID); 
     397        printf("HeadendID: %ld, ", headendID); 
     398        printf("TransponderID: %ld, ", transponderID); 
     399        printf("ServiceID: %ld\n\n", serviceID); 
     400         
     401        globals->activeDeviceID = deviceID; 
     402        globals->activePIDsCount = pidsCount; 
     403 
     404        for( i = 0; i < pidsCount; i++ ) 
     405        { 
     406            globals->activePIDs[i] = pidList[i]; 
     407            globals->seenPIDs[i] = 0; 
     408            printf("Active PID: %ld, type: %ld\n", pidList[i].pid, pidList[i].pidType); 
     409        } 
     410    } 
     411    printf(  "=====================================\n"); 
     412     
    562413    /* notify a potential VLC instance about the service change */ 
    563414    CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(), 
     
    574425/* EyeTVPluginDispatcher, 
    575426 * 
    576  * - selector : See 'EyeTVPluginDefs.h' 
    577  * - *refCon :  The RefCon to the plug-in-related Data 
    578  * - deviceID : Identifies the Device 
    579  * - params : Parameters for functioncall 
     427 *  - selector : See 'EyeTVPluginDefs.h' 
     428 *  - *refCon :  The RefCon to the plug-in-related Data 
     429 *  - deviceID : Identifies the Device 
     430 *  - params : Parameters for functioncall 
    580431 * 
    581432 * This function is a part of the interface for the communication with EyeTV. If something happens, 
     
    586437long EyeTVPluginDispatcher( EyeTVPluginParams* params ) 
    587438{ 
    588    long result = 0; 
    589  
    590    switch( params->selector )  
    591    
    592        case kEyeTVPluginSelector_Initialize: 
    593            result = VLCEyeTVPluginInitialize((VLCEyeTVPluginGlobals_t**)params->refCon,  
    594                                    params->initialize.apiVersion, params->initialize.callback); 
    595            break; 
    596              
    597        case kEyeTVPluginSelector_Terminate: 
    598            result = VLCEyeTVPluginTerminate((VLCEyeTVPluginGlobals_t*)params->refCon); 
    599            break; 
    600  
    601        case kEyeTVPluginSelector_GetInfo: 
    602            result = VLCEyeTVPluginGetInformation((VLCEyeTVPluginGlobals_t*)params->refCon,  
    603                                    params->info.pluginAPIVersion, params->info.pluginName, params->info.description); 
    604            break; 
    605  
    606        case kEyeTVPluginSelector_DeviceAdded: 
    607            result = VLCEyeTVPluginDeviceAdded((VLCEyeTVPluginGlobals_t*)params->refCon,  
    608                                    params->deviceID, params->deviceAdded.deviceType); 
    609            break; 
    610          
    611        case kEyeTVPluginSelector_DeviceRemoved: 
    612            result = VLCEyeTVPluginDeviceRemoved((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID); 
    613            break; 
    614  
    615        case kEyeTVPluginSelector_PacketsArrived: 
    616            result = VLCEyeTVPluginPacketsArrived((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID,  
    617                                    params->packetsArrived.packets, params->packetsArrived.packetCount); 
    618            break; 
    619  
    620        case kEyeTVPluginSelector_ServiceChanged: 
    621            result = VLCEyeTVPluginServiceChanged((VLCEyeTVPluginGlobals_t*)params->refCon,  
    622                                    params->deviceID, params->serviceChanged.headendID,  
    623                                    params->serviceChanged.transponderID, params->serviceChanged.serviceID,  
    624                                    params->serviceChanged.pidList, params->serviceChanged.pidCount); 
    625            break; 
    626    
    627  
    628    return result; 
    629 } 
     439    long result = 0; 
     440 
     441    switch( params->selector )  
     442   
     443        case kEyeTVPluginSelector_Initialize: 
     444            result = VLCEyeTVPluginInitialize((VLCEyeTVPluginGlobals_t**)params->refCon,  
     445                                    params->initialize.apiVersion, params->initialize.callback); 
     446            break; 
     447             
     448        case kEyeTVPluginSelector_Terminate: 
     449            result = VLCEyeTVPluginTerminate((VLCEyeTVPluginGlobals_t*)params->refCon); 
     450            break; 
     451 
     452        case kEyeTVPluginSelector_GetInfo: 
     453            result = VLCEyeTVPluginGetInformation((VLCEyeTVPluginGlobals_t*)params->refCon,  
     454                                    params->info.pluginAPIVersion, params->info.pluginName, params->info.description); 
     455            break; 
     456 
     457        case kEyeTVPluginSelector_DeviceAdded: 
     458            result = VLCEyeTVPluginDeviceAdded((VLCEyeTVPluginGlobals_t*)params->refCon,  
     459                                    params->deviceID, params->deviceAdded.deviceType); 
     460            break; 
     461         
     462        case kEyeTVPluginSelector_DeviceRemoved: 
     463            result = VLCEyeTVPluginDeviceRemoved((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID); 
     464            break; 
     465 
     466        case kEyeTVPluginSelector_PacketsArrived: 
     467            result = VLCEyeTVPluginPacketsArrived((VLCEyeTVPluginGlobals_t*)params->refCon, params->deviceID,  
     468                                    params->packetsArrived.packets, params->packetsArrived.packetCount); 
     469            break; 
     470 
     471        case kEyeTVPluginSelector_ServiceChanged: 
     472            result = VLCEyeTVPluginServiceChanged((VLCEyeTVPluginGlobals_t*)params->refCon,  
     473                                    params->deviceID, params->serviceChanged.headendID,  
     474                                    params->serviceChanged.transponderID, params->serviceChanged.serviceID,  
     475                                    params->serviceChanged.pidList, params->serviceChanged.pidCount); 
     476            break; 
     477   
     478 
     479    return result; 
     480} 
  • extras/MacOSX/eyetvplugin/eyetvplugin.h

    r10649df r36868ee  
    2323 
    2424#include "EyeTVPluginDefs.h" 
    25 #include <stdlib.h> 
    26 #include <string.h> 
    27 #include <stdio.h> 
    2825#include <CoreFoundation/CoreFoundation.h> 
    2926 
  • extras/MacOSX/eyetvplugin/eyetvplugin.xcodeproj/project.pbxproj

    r10649df r36868ee  
    123123            projectDirPath = ""; 
    124124            projectRoot = "";&