[Live-devel] Creating a RTSP stream from DVB-T hardware card
Ryan Walklin
ryanwalklin at gmail.com
Fri Jul 11 22:07:30 PDT 2008
A couple of other points, here is the structure of a transport packet
as given by EyeTV:
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;
And here is the code I'm currently using to access it:
static long PlexTVServerPacketsArrived(PlexTVServerGlobals *globals,
EyeTVPluginDeviceID deviceID, long **packets, long packetsCount)
{
long result = 0;
int i, j, isNewPID;
TransportStreamPacket *packet;
if (globals)
{
DeviceInfo *deviceInfo = GetDeviceInfo(globals, deviceID);
if (deviceInfo)
{
char packetBuffer[sizeof(TransportStreamPacket)];
for (i = 0; i < packetsCount; i++)
{
packet = (TransportStreamPacket*)packets[i];
isNewPID = 1;
/*
* search for PID
*/
for (j = 0; j < deviceInfo->pidsCount; j++)
{
if (packet->PID == deviceInfo->pids[j])
{
isNewPID = 0;
break;
}
}
/*
* add new PIDs to the DeviceInfo
*/
if (isNewPID)
{
#ifdef TVDBG_VERBOSE
printf ("PlexTVServer: SamplePacketsArrived, newPID = %6li\n",
packet->PID);
#endif
if (deviceInfo->pidsCount < MAX_PIDS)
{
deviceInfo->pids[deviceInfo->pidsCount++] = packet->PID;
}
}
//stream packets to RTSP server
memcpy(packetBuffer, packet, sizeof(TransportStreamPacket));
write(streamfd[STREAM_INPUT], packetBuffer,
sizeof(TransportStreamPacket));
}
//void *packetBuffer = malloc(packetsCount *
sizeof(TransportStreamPacket));
//memcpy(packetBuffer, packets, sizeof(TransportStreamPacket) *
packetsCount);
//write(streamfd[STREAM_INPUT], packetBuffer,
sizeof(TransportStreamPacket) * packetsCount);
//free(packetBuffer);
globals->packetCount+=packetsCount;
#ifdef TVDBG_VERBOSE
printf("Packetcount: %lli\n", globals->packetCount);
#endif
}
}
return result;
}
According to the EyeTV documentation, the **packets array is the
actual data coming from the card, rather than a copy, so it seems to
be quite sensitive to interference, hence copying the packets before
piping them to the server.
More information about the live-devel
mailing list