Commit 10649df7 authored by Felix Paul Kühne's avatar Felix Paul Kühne

* forward-port of all eyetv relates sources in my branch

    - this stuff is highly unfinished; needs much more work and testing
    - don't be surprised if you don't see anything when trying it out, this port is basically a big reminder for me to keep working on it ;-)
    - the access module is probably going to be ported from CoreFoundation-driven C to Cocoa-based Obj-C
    - everything will be 10.4-only, since EyeTV is only available this way as well
    - the plugin to put into EyeTV is compiled in UB-mode by default and incorporates Public Domain code provided by Elgato Systems GmbH
parent 906a3bfe
......@@ -5030,13 +5030,16 @@ AC_ARG_ENABLE(macosx,
[ --enable-macosx MacOS X support (default enabled on MacOS X)],
[if test "${enable_macosx}" = "yes"
then
VLC_ADD_BUILTINS([macosx])
VLC_ADD_LDFLAGS([macosx],[-framework IOKit -framework Cocoa -framework Carbon -framework QuickTime -lobjc -ObjC -framework OpenGL -framework AGL])
VLC_ADD_PLUGINS([access_eyetv])
VLC_ADD_LDFLAGS([access_eyetv], [-framework CoreFoundation])
VLC_ADD_LDFLAGS([macosx],[-framework IOKit -framework Cocoa -framework Carbon -framework QuickTime -lobjc -ObjC -framework OpenGL -framework AGL -framework QTKit])
VLC_ADD_OBJCFLAGS( [macosx],[-fobjc-exceptions] )
fi],
[AC_CHECK_HEADERS(Cocoa/Cocoa.h,
VLC_ADD_PLUGINS([access_eyetv])
VLC_ADD_LDFLAGS([access_eyetv], [-framework CoreFoundation])
VLC_ADD_BUILTINS([macosx])
VLC_ADD_LDFLAGS([macosx],[-framework IOKit -framework Cocoa -framework Carbon -framework QuickTime -lobjc -ObjC -framework OpenGL -framework AGL])
VLC_ADD_LDFLAGS([macosx],[-framework IOKit -framework Cocoa -framework Carbon -framework QuickTime -lobjc -ObjC -framework OpenGL -framework AGL -framework QTKit])
VLC_ADD_OBJCFLAGS( [macosx],[-fobjc-exceptions] )
)])
CFLAGS=$ORIGCFLAGS
......
B/* Localized versions of Info.plist keys */
/* This is public domain code developed by Elgato Systems GmbH. No GPL-covered
* changes were added to this file by any members of the VideoLAN team. If you
* want to do so, add a modified GPL header here, but keep a message emphasising
* the non-licensed parts of this header file.
* Ideally, VideoLAN-related changes should only go to eyetvplugin.h.
*
* $Id$
*/
#pragma once
/*
The EyeTV Plugin API
====================
The EyeTV Software gives third parties access to the incoming MPEG-2 transport stream.
At this time the API is available for the following products:
- EyeTV 200 (analog)
- EyeTV 300 (DVB-S)
- EyeTV 400 (DVB-T)
A plugin receives device plugged/unplugged notifications, it can request or release
individual PIDs and most importantly it has access to transport stream packets in
real time, as they arrive from the device. Note that the plugin is called before EyeTV
itself looks at the packets, so it is even possible to modify the data.
Plugins currently live in EyeTV.app/Contens/Plugins/
A plugin is packaged as a bundle with a single entry point:
long EyeTVPluginDispatcher(EyeTVPluginSelector selector,
void *refCon,
EyeTVPluginDeviceID deviceID,
long param1,
long param2,
long param3,
long param4);
PID Filtering
=============
EyeTV employs both hardware and software PID filtering. A plugin's dispatch routine
is called with the kEyeTVPluginSelector_PacketsArrived selector after the hardware
PID filter (naturally) but prior to the software PID filter, so the plugin has access
to all packets that are delivered by the hardware.
A plugin can request PIDs that are not needed by EyeTV from the hardware PID filter by
means of a callback routine, see eyeTVPluginSelector_SetCallback.
Note that hardware PID filtering is on for single processor machines (to reduce the CPU
load), but off for multi-processor machines (to improve channel switch times).
This behaviour is controlled by the "hardware PID filter" key in com.elgato.eyetv.plist,
which defaults to "Auto" ("Off" on MP machines, "On" on single-processor machines). EyeTV
does not offer GUI to change this setting. A plugin hence needs to be prepared to handle
both an entire transponder or multiplex and to request PIDs it might need.
Note that the plugin is called on the real-time thread that receives the transport stream
packets and that the packet buffers passed to the plugin are the actual hardware DMA buffers.
Please return as quickly as possible from the kEyeTVPluginSelector_PacketsArrived call and
avoid blocking the calling thread.
Revision History:
02/27/2004: Initial Release.
*/
#define EYETV_PLUGIN_API_VERSION 0x04021901
#define EYETV_PLUGIN_API_MIN_VERSION 0x04021901
typedef long long EyeTVPluginDeviceID;
typedef long EyeTVPluginDeviceType;
typedef long EyeTVPluginSelector;
enum {
kEyeTVPIDType_Video = 0,
kEyeTVPIDType_MPEGAudio = 1,
kEyeTVPIDType_VBI = 2, /* teletext */
kEyeTVPIDType_PCR = 3,
kEyeTVPIDType_PMT = 4,
kEyeTVPIDType_Unknown = 5,
kEyeTVPIDType_AC3Audio = 6
};
typedef struct EyeTVPluginPIDInfo EyeTVPluginPIDInfo;
struct EyeTVPluginPIDInfo {
long pid;
long pidType;
};
/***********************************************************************************
*
* EyeTVPluginCallbackParams,
*
***********************************************************************************/
enum {
kEyeTVPluginCallbackSelector_RetainPIDs = 0,
kEyeTVPluginCallbackSelector_ReleasePIDs = 1
};
typedef struct EyeTVPluginCallbackParams EyeTVPluginCallbackParams;
struct EyeTVPluginCallbackParams {
EyeTVPluginDeviceID deviceID; // the deviceID
long selector; // callback selector, see above
long *pids; // list of pids to release/retain
long pidsCount; // count of pids
};
/***********************************************************************************
*
* typedef for the callback function,
*
***********************************************************************************/
typedef long(* EyeTVPluginCallbackProc)(EyeTVPluginCallbackParams *params);
/***********************************************************************************
*
* EyeTVPluginParamStructs
*
***********************************************************************************/
typedef struct EyeTVPluginInitializeParams EyeTVPluginInitializeParams;
struct EyeTVPluginInitializeParams {
long apiVersion; // version of the EyeTV_PLUGIN_API
EyeTVPluginCallbackProc callback; // the callback
}; /* 8 bytes */
typedef struct EyeTVPluginGetInfoParams EyeTVPluginGetInfoParams;
struct EyeTVPluginGetInfoParams {
long *pluginAPIVersion; // <- EYETV_PLUGIN_API_VERSION
char *pluginName; // <- points to a 128-byte buffer, the plugin is expected to fill the buffer with
// a UTF-8 encoded string.
char *description; // <- points to a 1024-byte buffer, the plugin is expected to fill the buffer with
// a UTF-8 encoded string describing the plugin.
}; /* 12 bytes */
enum {
kEyeTVPluginDeviceType_Unknown = 0,
kEyeTVPluginDeviceType_e200 = 1,
kEyeTVPluginDeviceType_e300 = 2,
kEyeTVPluginDeviceType_e400 = 3
} ;
typedef struct EyeTVPluginDeviceAddedParams EyeTVPluginDeviceAddedParams;
struct EyeTVPluginDeviceAddedParams {
EyeTVPluginDeviceType deviceType;
}; /* 4 bytes */
typedef struct EyeTVPluginPacketsArrivedParams EyeTVPluginPacketsArrivedParams;
struct EyeTVPluginPacketsArrivedParams {
long **packets; // points to an array of packets
long packetCount;
}; /* 8 bytes */
typedef struct EyeTVPluginServiceChangedParams EyeTVPluginServiceChangedParams;
struct EyeTVPluginServiceChangedParams {
long headendID; // new headend ID. For E300 it's the orbital position of the satellite
// in tenth of a degree
long transponderID; // new transponder ID (The Frequency in kHz)
long serviceID; // new service ID (the ID of the used service as included in the DVB Stream)
EyeTVPluginPIDInfo *pidList; // points to the list of active PIDs;
long pidCount; // the length of pidList
}; /* 20 bytes */
/***********************************************************************************
*
* EyeTVPluginParams
*
***********************************************************************************/
typedef struct EyeTVPluginParams EyeTVPluginParams;
struct EyeTVPluginParams {
EyeTVPluginDeviceID deviceID; // ID of the device
EyeTVPluginSelector selector; // selector
void *refCon; // refCon
union {
EyeTVPluginInitializeParams initialize; // kEyeTVPluginSelector_Initialize
// kEyeTVPluginSelector_Terminate, no additional parameters
EyeTVPluginGetInfoParams info; // kEyeTVPluginSelector_GetInfo
EyeTVPluginDeviceAddedParams deviceAdded; // kEyeTVPluginSelector_DeviceAdded
// kEyeTVPluginSelector_DeviceRemoved, no additional parameters
EyeTVPluginPacketsArrivedParams packetsArrived; // kEyeTVPluginSelector_PacketsArrived
EyeTVPluginServiceChangedParams serviceChanged; // kEyeTVPluginSelector_ServiceChanged
};
};
enum { // EyeTVPluginSelector
kEyeTVPluginSelector_Initialize = 0,
kEyeTVPluginSelector_Terminate = 1,
kEyeTVPluginSelector_GetInfo = 2,
kEyeTVPluginSelector_DeviceAdded = 3,
kEyeTVPluginSelector_DeviceRemoved = 4,
kEyeTVPluginSelector_PacketsArrived = 5,
kEyeTVPluginSelector_ServiceChanged = 6
};
/***********************************************************************************
*
* EyeTVPluginEntryProc
*
***********************************************************************************/
typedef long(* EyeTVPluginEntryProc)(EyeTVPluginParams *params);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.videolan.vlceyetvplugin</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<string>MyFactoryFunction</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<array>
<string>00000000-0000-0000-0000-000000000000</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
</dict>
</plist>
/*****************************************************************************
* eyetvplugin.c: Plug-In for the EyeTV software to connect to VLC
*****************************************************************************
* Copyright (C) 2006-2007 the VideoLAN team
* $Id$
*
* Authors: Felix Kühne <fkuehne at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "eyetvplugin.h"
#define MAX_PIDS 256
#define MAX_ACTIVE_PIDS 256
#define MAX_DEVICES 16
#define VLC_NOTIFICATION_OBJECT "VLCEyeTVSupport"
#pragma push
#pragma pack(1)
/* Structure for TS-Packets */
typedef struct
{
unsigned long sync_byte : 8,
transport_error_indicator : 1,
payload_unit_start_indicator : 1,
transport_priority : 1,
PID : 13,
transport_scrambling_control : 2,
adaptation_field_control : 2,
continuity_counter : 4;
unsigned char data[188-4];
} TransportStreamPacket;
#pragma pop
/* Structure to hold Information on devices */
typedef struct
{
EyeTVPluginDeviceID deviceID;
EyeTVPluginDeviceType deviceType;
long headendID;
long transponderID;
long serviceID;
long pidsCount;
long pids[MAX_PIDS];
EyeTVPluginPIDInfo activePIDs[MAX_ACTIVE_PIDS];
long activePIDsCount;
} DeviceInfo;
/* Structure to hold global data to communicate with EyeTV */
typedef struct
{
EyeTVPluginCallbackProc callback;
long deviceCount;
DeviceInfo devices[MAX_DEVICES];
long long packetCount;
} VLCEyeTVPluginGlobals_t;
/* 2nd structure to store our own global data which isn't shared with EyeTV
* a bit empty at the moment, but it will get larger as development progresses */
typedef struct
{
int i_deviceCount;
CFMessagePortRef messagePortToVLC;
bool b_msgPortOpen;
} VLCEyeTVPluginOwnGlobals_t;
VLCEyeTVPluginOwnGlobals_t *nativeGlobals;
/* return the DeviceInfo with ID deviceID */
static DeviceInfo *GetDeviceInfo(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID)
{
int i;
if( globals )
{
for( i=0; i<globals->deviceCount; i++)
{
if( globals->devices[i].deviceID == deviceID )
{
return &globals->devices[i];
}
}
}
return NULL;
}
#pragma mark -
/* initialise the plug-in */
static long VLCEyeTVPluginInitialize(VLCEyeTVPluginGlobals_t** globals, long apiVersion, EyeTVPluginCallbackProc callback)
{
printf("VLC media player Plug-In: Initialize\n");
long result = 0;
/* init our own storage */
extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals;
nativeGlobals = malloc( sizeof( VLCEyeTVPluginOwnGlobals_t ) );
/* notify a potential VLC instance about our initialisation */
CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),
CFSTR("PluginInit"),
CFSTR(VLC_NOTIFICATION_OBJECT),
/*userInfo*/ NULL,
TRUE );
/* init our notification support */
CFNotificationCenterAddObserver( CFNotificationCenterGetDistributedCenter(),
/* observer */ NULL,
/* callBack */ VLCEyeTVPluginGlobalNotificationReceived,
/* name, NULL==all */ NULL,
CFSTR(VLC_NOTIFICATION_OBJECT),
CFNotificationSuspensionBehaviorDeliverImmediately );
*globals = (VLCEyeTVPluginGlobals_t *) calloc(1, sizeof( VLCEyeTVPluginGlobals_t ) );
( *globals )->callback = callback;
return result;
}
/* we will be terminated soon, clean up */
static long VLCEyeTVPluginTerminate(VLCEyeTVPluginGlobals_t *globals)
{
extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals;
printf("VLC media player Plug-In: Terminate\n");
long result = 0;
/* notify a potential VLC instance about our termination */
CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter (),
CFSTR("PluginQuit"),
CFSTR(VLC_NOTIFICATION_OBJECT),
/*userInfo*/ NULL,
TRUE );
/* remove us from the global notification centre */
CFNotificationCenterRemoveEveryObserver( CFNotificationCenterGetDistributedCenter(),
(void *)VLCEyeTVPluginGlobalNotificationReceived );
/* invalidate and free msg port */
if( nativeGlobals->messagePortToVLC )
{
CFMessagePortInvalidate( nativeGlobals->messagePortToVLC );
free( nativeGlobals->messagePortToVLC );
printf( "msgport invalidated and freed\n" );
}
else
printf( "no msgport to free\n" );
if( globals )
{
free( globals );
}
if( nativeGlobals )
free( nativeGlobals );
return result;
}
/* called when EyeTV asks various stuff about us */
static long VLCEyeTVPluginGetInformation(VLCEyeTVPluginGlobals_t *globals, long* outAPIVersion, char* outName, char *outDescription)
{
printf("VLC media player Plug-In: GetInfo\n");
long result = 0;
if( globals )
{
if( outAPIVersion )
{
*outAPIVersion = EYETV_PLUGIN_API_VERSION;
}
if( outName )
{
char* name = "VLC media player Plug-In";
strcpy( &outName[0], name);
}
if( outDescription )
{
char* desc = "This Plug-In connects EyeTV to the VLC media player for streaming purposes.";
strcpy( &outDescription[0], desc);
}
}
return result;
}
/* called if we received a global notification */
void VLCEyeTVPluginGlobalNotificationReceived( CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo )
{
CFIndex maxlen;
char *theName, *theObject;
extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals;
maxlen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( name ),
kCFStringEncodingUTF8) + 1;
theName = malloc(maxlen);
CFStringGetCString( name,
theName,
maxlen,
kCFStringEncodingUTF8);
maxlen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( name ),
kCFStringEncodingUTF8) + 1;
theObject = malloc(maxlen);
CFStringGetCString( object,
theObject,
maxlen,
kCFStringEncodingUTF8);
printf( "notication received with name: %s and object: %s\n", theName, theObject );
/* when VLC launches after us, we need to inform it about our existance and the current state of available devices */
if( CFStringCompare( name, CFSTR( "VLCOSXGUIInit" ), 0) == kCFCompareEqualTo )
{
/* we're here */
CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter (),
CFSTR("PluginInit"),
CFSTR(VLC_NOTIFICATION_OBJECT),
/*userInfo*/ NULL,
TRUE );
if( nativeGlobals && ( nativeGlobals->i_deviceCount > 0 ) )
{
/* at least one device is apparently connected */
CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter (),
CFSTR("DeviceAdded"),
CFSTR(VLC_NOTIFICATION_OBJECT),
/*userInfo*/ NULL,
TRUE );
}
}
/* VLC wants us to start sending data */
if( CFStringCompare( name, CFSTR( "VLCAccessStartDataSending" ), 0) == kCFCompareEqualTo )
{
nativeGlobals->messagePortToVLC = CFMessagePortCreateRemote( kCFAllocatorDefault,
CFSTR("VLCEyeTVMsgPort") );
if( nativeGlobals->messagePortToVLC == NULL )
printf( "getting messagePortToVLC failed!\n" );
else
{
nativeGlobals->b_msgPortOpen = TRUE;
printf( "msg port opened / data sending switched on\n" );
}
}
/* VLC wants us to stop sending data */
if( CFStringCompare( name, CFSTR( "VLCAccessStopDataSending" ), 0) == kCFCompareEqualTo )
{
nativeGlobals->b_msgPortOpen = FALSE;
printf( "data sending switched off\n" );
}
}
/* called if a device is added */
static long VLCEyeTVPluginDeviceAdded(VLCEyeTVPluginGlobals_t *globals, EyeTVPluginDeviceID deviceID, EyeTVPluginDeviceType deviceType)
{
printf("VLC media player Plug-In: Device with type %i and ID %i added\n", (int)deviceType, (int)deviceID);
long result = 0;
DeviceInfo *deviceInfo;
extern VLCEyeTVPluginOwnGlobals_t *nativeGlobals;
if( globals )
{
if( globals->deviceCount < MAX_DEVICES )
{
deviceInfo = &( globals->devices[globals->deviceCount] );
memset(deviceInfo, 0, sizeof(DeviceInfo));
deviceInfo->deviceID = deviceID;
deviceInfo->deviceType = deviceType;
globals->deviceCount++;
if( nativeGlobals )
nativeGlobals->i_deviceCount = globals->deviceCount;
/* notify a potential VLC instance about the addition */
CFNotificationCenterPostNotification( CFNotificationCenterGetDistributedCenter(),
CFSTR("DeviceAdded"),
CFSTR(VLC_NOTIFICATION_OBJECT),
/*userInfo*/ NULL,
TRUE );