mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 23:43:00 +02:00
libeplayer3: run through indent, no binary change
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ if (debug_level >= level) fprintf(stderr, x); } while (0)
|
||||
#define cERR_OUTPUT_NO_ERROR 0
|
||||
#define cERR_OUTPUT_INTERNAL_ERROR -1
|
||||
|
||||
static const char* FILENAME = "output.c";
|
||||
static const char *FILENAME = "output.c";
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
@@ -63,7 +63,7 @@ static const char* FILENAME = "output.c";
|
||||
/* Varaibles */
|
||||
/* ***************************** */
|
||||
|
||||
static Output_t * AvailableOutput[] = {
|
||||
static Output_t *AvailableOutput[] = {
|
||||
&LinuxDvbOutput,
|
||||
&SubtitleOutput,
|
||||
&PipeOutput,
|
||||
@@ -78,18 +78,19 @@ static Output_t * AvailableOutput[] = {
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static void printOutputCapabilities() {
|
||||
static void printOutputCapabilities()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
output_printf(10, "Capabilities:\n");
|
||||
|
||||
for (i = 0; AvailableOutput[i] != NULL; i++) {
|
||||
output_printf(10, "\t%s : ", AvailableOutput[i]->Name);
|
||||
for (i = 0; AvailableOutput[i] != NULL; i++) {
|
||||
output_printf(10, "\t%s : ", AvailableOutput[i]->Name);
|
||||
|
||||
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
|
||||
output_printf(10, "%s ", AvailableOutput[i]->Capabilities[j]);
|
||||
output_printf(10, "\n");
|
||||
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
|
||||
output_printf(10, "%s ", AvailableOutput[i]->Capabilities[j]);
|
||||
output_printf(10, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,301 +98,451 @@ static void printOutputCapabilities() {
|
||||
/* Output Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static void OutputAdd(Context_t *context, char * port) {
|
||||
static void OutputAdd(Context_t * context, char *port)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
for (i = 0; AvailableOutput[i] != NULL; i++)
|
||||
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
|
||||
if (!strcmp(AvailableOutput[i]->Capabilities[j], port)) {
|
||||
if (!strcmp("audio", port)) {
|
||||
context->output->audio = AvailableOutput[i];
|
||||
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
|
||||
if (!strcmp(AvailableOutput[i]->Capabilities[j], port)) {
|
||||
if (!strcmp("audio", port)) {
|
||||
context->output->audio = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
if (!strcmp("video", port)) {
|
||||
context->output->video = AvailableOutput[i];
|
||||
if (!strcmp("video", port)) {
|
||||
context->output->video = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
if (!strcmp("subtitle", port)) {
|
||||
context->output->subtitle = AvailableOutput[i];
|
||||
if (!strcmp("subtitle", port)) {
|
||||
context->output->subtitle = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
if (!strcmp("dvbsubtitle", port)) {
|
||||
context->output->dvbsubtitle = AvailableOutput[i];
|
||||
if (!strcmp("dvbsubtitle", port)) {
|
||||
context->output->dvbsubtitle = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
if (!strcmp("teletext", port)) {
|
||||
context->output->teletext = AvailableOutput[i];
|
||||
if (!strcmp("teletext", port)) {
|
||||
context->output->teletext = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void OutputDel(Context_t *context, char * port) {
|
||||
static void OutputDel(Context_t * context, char *port)
|
||||
{
|
||||
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
if (!strcmp("audio", port))
|
||||
context->output->audio = NULL;
|
||||
context->output->audio = NULL;
|
||||
else if (!strcmp("video", port))
|
||||
context->output->video = NULL;
|
||||
context->output->video = NULL;
|
||||
else if (!strcmp("subtitle", port))
|
||||
context->output->subtitle = NULL;
|
||||
context->output->subtitle = NULL;
|
||||
else if (!strcmp("dvbsubtitle", port))
|
||||
context->output->dvbsubtitle = NULL;
|
||||
context->output->dvbsubtitle = NULL;
|
||||
else if (!strcmp("teletext", port))
|
||||
context->output->teletext = NULL;
|
||||
context->output->teletext = NULL;
|
||||
|
||||
}
|
||||
|
||||
static int Command(void *_context, OutputCmd_t command, void * argument) {
|
||||
Context_t *context = (Context_t*) _context;
|
||||
static int Command(void *_context, OutputCmd_t command, void *argument)
|
||||
{
|
||||
Context_t *context = (Context_t *) _context;
|
||||
int ret = cERR_OUTPUT_NO_ERROR;
|
||||
|
||||
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__, command);
|
||||
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__,
|
||||
command);
|
||||
|
||||
switch(command) {
|
||||
case OUTPUT_OPEN: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_OPEN, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_OPEN, "audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |= context->output->subtitle->Command(context, OUTPUT_OPEN, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLOSE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_CLOSE, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_CLOSE, "audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |= context->output->subtitle->Command(context, OUTPUT_CLOSE, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_ADD: {
|
||||
OutputAdd(context, (char*) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_DEL: {
|
||||
OutputDel(context, (char*) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CAPABILITIES: {
|
||||
printOutputCapabilities();
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PLAY: { // 4
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret = context->output->video->Command(context, OUTPUT_PLAY, "video");
|
||||
|
||||
if (!ret) { // success or not executed, dunn care
|
||||
if (context->playback->isAudio)
|
||||
ret = context->output->audio->Command(context, OUTPUT_PLAY, "audio");
|
||||
|
||||
if (!ret) { // success or not executed, dunn care
|
||||
if (context->playback->isSubtitle)
|
||||
ret = context->output->subtitle->Command(context, OUTPUT_PLAY, "subtitle");
|
||||
}
|
||||
switch (command) {
|
||||
case OUTPUT_OPEN:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_OPEN,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_OPEN,
|
||||
"audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |=
|
||||
context->output->subtitle->Command(context,
|
||||
OUTPUT_OPEN,
|
||||
"subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
}
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_STOP: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_STOP, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_STOP, "audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |= context->output->subtitle->Command(context, OUTPUT_STOP, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FLUSH: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_FLUSH, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_FLUSH, "audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_FLUSH, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PAUSE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_PAUSE, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_PAUSE, "audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FASTFORWARD: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_FASTFORWARD, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_FASTFORWARD, "audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_REVERSE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_REVERSE, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_REVERSE, "audio");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CONTINUE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_CONTINUE, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_CONTINUE, "audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_CONTINUE, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_AVSYNC: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo && context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_AVSYNC, "audio");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLEAR: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo && (argument == NULL || *(char *) argument == 'v'))
|
||||
ret |= context->output->video->Command(context, OUTPUT_CLEAR, "video");
|
||||
if (context->playback->isAudio && (argument == NULL || *(char *) argument == 'a'))
|
||||
ret |= context->output->audio->Command(context, OUTPUT_CLEAR, "audio");
|
||||
//if (context->playback->isSubtitle && (argument == NULL || *(char *) argument == 's'))
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_CLEAR, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PTS: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context, OUTPUT_PTS, argument);
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context, OUTPUT_PTS, argument);
|
||||
//if (context->playback->isSubtitle)
|
||||
// return context->output->subtitle->Command(context, OUTPUT_PTS, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SWITCH: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context, OUTPUT_SWITCH, "audio");
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context, OUTPUT_SWITCH, "video");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |= context->output->teletext->Command(context, command, "teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SLOWMOTION: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_SLOWMOTION, "video");
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_SLOWMOTION, "audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_AUDIOMUTE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isAudio)
|
||||
ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (char*) argument);
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_DISCONTINUITY_REVERSE: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (void*) argument);
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_GET_FRAME_COUNT: {
|
||||
if (context && context->playback ) {
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, argument);
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, argument);
|
||||
//if (context->playback->isSubtitle)
|
||||
// return context->output->subtitle->Command(context, OUTPUT_GET_FRAME_COUNT, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLOSE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_CLOSE,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_CLOSE,
|
||||
"audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |=
|
||||
context->output->subtitle->Command(context,
|
||||
OUTPUT_CLOSE,
|
||||
"subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_ADD:{
|
||||
OutputAdd(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_DEL:{
|
||||
OutputDel(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CAPABILITIES:{
|
||||
printOutputCapabilities();
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PLAY:{ // 4
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret =
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_PLAY,
|
||||
"video");
|
||||
|
||||
if (!ret) { // success or not executed, dunn care
|
||||
if (context->playback->isAudio)
|
||||
ret =
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_PLAY,
|
||||
"audio");
|
||||
|
||||
if (!ret) { // success or not executed, dunn care
|
||||
if (context->playback->isSubtitle)
|
||||
ret =
|
||||
context->output->subtitle->Command(context,
|
||||
OUTPUT_PLAY,
|
||||
"subtitle");
|
||||
}
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
}
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_STOP:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_STOP,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_STOP,
|
||||
"audio");
|
||||
if (context->playback->isSubtitle)
|
||||
ret |=
|
||||
context->output->subtitle->Command(context,
|
||||
OUTPUT_STOP,
|
||||
"subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FLUSH:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_FLUSH,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_FLUSH,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_FLUSH, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PAUSE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_PAUSE,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_PAUSE,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FASTFORWARD:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_FASTFORWARD,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_FASTFORWARD,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_REVERSE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_REVERSE,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_REVERSE,
|
||||
"audio");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CONTINUE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_CONTINUE,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_CONTINUE,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_CONTINUE, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_AVSYNC:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo
|
||||
&& context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_AVSYNC,
|
||||
"audio");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLEAR:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo
|
||||
&& (argument == NULL || *(char *) argument == 'v'))
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_CLEAR,
|
||||
"video");
|
||||
if (context->playback->isAudio
|
||||
&& (argument == NULL || *(char *) argument == 'a'))
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_CLEAR,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle && (argument == NULL || *(char *) argument == 's'))
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_CLEAR, "subtitle");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PTS:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context,
|
||||
OUTPUT_PTS,
|
||||
argument);
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context,
|
||||
OUTPUT_PTS,
|
||||
argument);
|
||||
//if (context->playback->isSubtitle)
|
||||
// return context->output->subtitle->Command(context, OUTPUT_PTS, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SWITCH:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context,
|
||||
OUTPUT_SWITCH,
|
||||
"audio");
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context,
|
||||
OUTPUT_SWITCH,
|
||||
"video");
|
||||
if (context->playback->isDvbSubtitle)
|
||||
ret |=
|
||||
context->output->dvbsubtitle->Command(context,
|
||||
command,
|
||||
"dvbsubtitle");
|
||||
if (context->playback->isTeletext)
|
||||
ret |=
|
||||
context->output->teletext->Command(context,
|
||||
command,
|
||||
"teletext");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SLOWMOTION:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_SLOWMOTION,
|
||||
"video");
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_SLOWMOTION,
|
||||
"audio");
|
||||
//if (context->playback->isSubtitle)
|
||||
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_AUDIOMUTE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isAudio)
|
||||
ret |=
|
||||
context->output->audio->Command(context,
|
||||
OUTPUT_AUDIOMUTE,
|
||||
(char *) argument);
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_DISCONTINUITY_REVERSE:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
ret |=
|
||||
context->output->video->Command(context,
|
||||
OUTPUT_DISCONTINUITY_REVERSE,
|
||||
(void *) argument);
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
case OUTPUT_GET_FRAME_COUNT:{
|
||||
if (context && context->playback) {
|
||||
if (context->playback->isVideo)
|
||||
return context->output->video->Command(context,
|
||||
OUTPUT_GET_FRAME_COUNT,
|
||||
argument);
|
||||
if (context->playback->isAudio)
|
||||
return context->output->audio->Command(context,
|
||||
OUTPUT_GET_FRAME_COUNT,
|
||||
argument);
|
||||
//if (context->playback->isSubtitle)
|
||||
// return context->output->subtitle->Command(context, OUTPUT_GET_FRAME_COUNT, "subtitle");
|
||||
} else
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME,
|
||||
__FUNCTION__, command);
|
||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
output_printf(10, "%s::%s exiting with value %d\n", FILENAME, __FUNCTION__, ret);
|
||||
output_printf(10, "%s::%s exiting with value %d\n", FILENAME,
|
||||
__FUNCTION__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -401,7 +552,7 @@ OutputHandler_t OutputHandler = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, // dvbsubtitle
|
||||
NULL, // teletext
|
||||
NULL, // dvbsubtitle
|
||||
NULL, // teletext
|
||||
&Command
|
||||
};
|
||||
|
@@ -70,24 +70,28 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x );
|
||||
#define cERR_PIPE_NO_ERROR 0
|
||||
#define cERR_PIPE_ERROR -1
|
||||
|
||||
static const char TELETEXTPIPE[] = "/tmp/.eplayer3_teletext";
|
||||
static const char DVBSUBTITLEPIPE[] = "/tmp/.eplayer3_dvbsubtitle";
|
||||
static const char TELETEXTPIPE[] = "/tmp/.eplayer3_teletext";
|
||||
static const char DVBSUBTITLEPIPE[] = "/tmp/.eplayer3_dvbsubtitle";
|
||||
|
||||
static int teletextfd = -1;
|
||||
static int dvbsubtitlefd = -1;
|
||||
static int teletextfd = -1;
|
||||
static int dvbsubtitlefd = -1;
|
||||
|
||||
pthread_mutex_t Pipemutex;
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
int PipeStop(Context_t *context, char * type);
|
||||
int PipeStop(Context_t * context, char *type);
|
||||
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
void getPipeMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) {
|
||||
void getPipeMutex(const char *filename
|
||||
__attribute__ ((unused)), const char *function
|
||||
__attribute__ ((unused)), int line
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
|
||||
pipe_printf(250, "requesting mutex\n");
|
||||
|
||||
@@ -96,46 +100,52 @@ void getPipeMutex(const char *filename __attribute__((unused)), const char *func
|
||||
pipe_printf(250, "received mutex\n");
|
||||
}
|
||||
|
||||
void releasePipeMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) {
|
||||
void releasePipeMutex(const char *filename
|
||||
__attribute__ ((unused)), const char *function
|
||||
__attribute__ ((unused)), int line
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
pthread_mutex_unlock(&Pipemutex);
|
||||
|
||||
pipe_printf(250, "released mutex\n");
|
||||
|
||||
}
|
||||
|
||||
int PipeOpen(Context_t *context __attribute__((unused)), char * type) {
|
||||
int PipeOpen(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
|
||||
|
||||
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
|
||||
|
||||
if (teletext && teletextfd == -1) {
|
||||
mkfifo(TELETEXTPIPE, 0644);
|
||||
teletextfd = open(TELETEXTPIPE, O_RDWR | O_NONBLOCK);
|
||||
mkfifo(TELETEXTPIPE, 0644);
|
||||
teletextfd = open(TELETEXTPIPE, O_RDWR | O_NONBLOCK);
|
||||
|
||||
if (teletextfd < 0)
|
||||
{
|
||||
pipe_err("failed to open %s - errno %d\n", TELETEXTPIPE, errno);
|
||||
pipe_err("%s\n", strerror(errno));
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
if (teletextfd < 0) {
|
||||
pipe_err("failed to open %s - errno %d\n", TELETEXTPIPE,
|
||||
errno);
|
||||
pipe_err("%s\n", strerror(errno));
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
}
|
||||
if (dvbsubtitle && dvbsubtitlefd == -1) {
|
||||
mkfifo(DVBSUBTITLEPIPE, 0644);
|
||||
dvbsubtitlefd = open(DVBSUBTITLEPIPE, O_RDWR | O_NONBLOCK);
|
||||
mkfifo(DVBSUBTITLEPIPE, 0644);
|
||||
dvbsubtitlefd = open(DVBSUBTITLEPIPE, O_RDWR | O_NONBLOCK);
|
||||
|
||||
if (dvbsubtitlefd < 0)
|
||||
{
|
||||
pipe_err("failed to open %s - errno %d\n", DVBSUBTITLEPIPE, errno);
|
||||
pipe_err("%s\n", strerror(errno));
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
if (dvbsubtitlefd < 0) {
|
||||
pipe_err("failed to open %s - errno %d\n", DVBSUBTITLEPIPE,
|
||||
errno);
|
||||
pipe_err("%s\n", strerror(errno));
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
int PipeClose(Context_t *context, char * type) {
|
||||
int PipeClose(Context_t * context, char *type)
|
||||
{
|
||||
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
@@ -147,22 +157,24 @@ int PipeClose(Context_t *context, char * type) {
|
||||
*/
|
||||
PipeStop(context, type);
|
||||
|
||||
getPipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
close(dvbsubtitlefd);
|
||||
dvbsubtitlefd = -1;
|
||||
close(dvbsubtitlefd);
|
||||
dvbsubtitlefd = -1;
|
||||
}
|
||||
if (teletext && teletextfd != -1) {
|
||||
close(teletextfd);
|
||||
teletextfd = -1;
|
||||
close(teletextfd);
|
||||
teletextfd = -1;
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
int PipePlay(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
|
||||
int PipePlay(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
#if 0
|
||||
@@ -179,7 +191,9 @@ int PipePlay(Context_t *context __attribute__((unused)), char * type __attribut
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeStop(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
|
||||
int PipeStop(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
#if 0
|
||||
@@ -188,38 +202,40 @@ int PipeStop(Context_t *context __attribute__((unused)), char * type __attribut
|
||||
|
||||
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
|
||||
|
||||
getPipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
}
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeFlush(Context_t *context __attribute__((unused)), char * type) {
|
||||
int PipeFlush(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
|
||||
|
||||
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
if ((dvbsubtitle && dvbsubtitlefd != -1)
|
||||
|| (teletext && teletextfd != -1)) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
char buf[65536];
|
||||
while(0 < read(dvbsubtitlefd, buf, sizeof(buf)));
|
||||
while (0 < read(dvbsubtitlefd, buf, sizeof(buf)));
|
||||
}
|
||||
if (teletext && teletextfd != -1) {
|
||||
char buf[65536];
|
||||
while(0 < read(teletextfd, buf, sizeof(buf)));
|
||||
while (0 < read(teletextfd, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
pipe_printf(10, "exiting\n");
|
||||
@@ -227,26 +243,28 @@ int PipeFlush(Context_t *context __attribute__((unused)), char * type) {
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
int PipeClear(Context_t *context __attribute__((unused)), char * type) {
|
||||
int PipeClear(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "v%d a%d\n", dvbsubtitle, teletext);
|
||||
|
||||
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
if ((dvbsubtitle && dvbsubtitlefd != -1)
|
||||
|| (teletext && teletextfd != -1)) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
char buf[65536];
|
||||
while(0 < read(dvbsubtitlefd, buf, sizeof(buf)));
|
||||
while (0 < read(dvbsubtitlefd, buf, sizeof(buf)));
|
||||
}
|
||||
if (teletext && teletextfd != -1) {
|
||||
char buf[65536];
|
||||
while(0 < read(teletextfd, buf, sizeof(buf)));
|
||||
while (0 < read(teletextfd, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
pipe_printf(10, "exiting\n");
|
||||
@@ -254,23 +272,26 @@ int PipeClear(Context_t *context __attribute__((unused)), char * type) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeSwitch(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
|
||||
int PipeSwitch(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
#if 0
|
||||
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "v%d a%d\n", dvbsubtitle, teletext);
|
||||
|
||||
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
if ((dvbsubtitle && dvbsubtitlefd != -1)
|
||||
|| (teletext && teletextfd != -1)) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
}
|
||||
if (dvbsubtitle && dvbsubtitlefd != -1) {
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__,__LINE__);
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
}
|
||||
|
||||
@@ -279,11 +300,12 @@ int PipeSwitch(Context_t *context __attribute__((unused)), char * type __attrib
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
static int writePESDataTeletext(int fd, unsigned char *data, size_t data_len)
|
||||
static int writePESDataTeletext(int fd, unsigned char *data,
|
||||
size_t data_len)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
if (data_len > 0) {
|
||||
len = data_len + 39;
|
||||
len = data_len + 39;
|
||||
char header[45];
|
||||
memset(header, 0, sizeof(header));
|
||||
header[2] = 0x01;
|
||||
@@ -299,17 +321,18 @@ static int writePESDataTeletext(int fd, unsigned char *data, size_t data_len)
|
||||
if (len != iov[0].iov_len + iov[1].iov_len) {
|
||||
// writing to pipe failed, clear it.
|
||||
char buf[65536];
|
||||
while(0 < read(fd, buf, sizeof(buf)));
|
||||
while (0 < read(fd, buf, sizeof(buf)));
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static int writePESDataDvbsubtitle(int fd, unsigned char *data, size_t data_len, int64_t pts)
|
||||
static int writePESDataDvbsubtitle(int fd, unsigned char *data,
|
||||
size_t data_len, int64_t pts)
|
||||
{
|
||||
int len = 0;
|
||||
if (data_len > 0) {
|
||||
len = data_len + 10;
|
||||
len = data_len + 10;
|
||||
char header[16];
|
||||
memset(header, 0, sizeof(header));
|
||||
header[2] = 0x01;
|
||||
@@ -318,16 +341,16 @@ static int writePESDataDvbsubtitle(int fd, unsigned char *data, size_t data_len,
|
||||
header[5] = len & 0xff;
|
||||
|
||||
if (pts) {
|
||||
header[7] = 0x80;
|
||||
header[13] = 0x01 | ((pts << 1) & 0xff);
|
||||
pts >>= 7;
|
||||
header[12] = pts & 0xff;
|
||||
pts >>=8;
|
||||
header[11] = 0x01 | ((pts << 1) & 0xff);
|
||||
pts >>= 7;
|
||||
header[10] = pts & 0xff;
|
||||
pts >>=8;
|
||||
header[9] = 0x21 | ((pts << 1) & 0xff);
|
||||
header[7] = 0x80;
|
||||
header[13] = 0x01 | ((pts << 1) & 0xff);
|
||||
pts >>= 7;
|
||||
header[12] = pts & 0xff;
|
||||
pts >>= 8;
|
||||
header[11] = 0x01 | ((pts << 1) & 0xff);
|
||||
pts >>= 7;
|
||||
header[10] = pts & 0xff;
|
||||
pts >>= 8;
|
||||
header[9] = 0x21 | ((pts << 1) & 0xff);
|
||||
}
|
||||
header[8] = 14 - 9;
|
||||
header[14] = 0x20;
|
||||
@@ -337,104 +360,105 @@ static int writePESDataDvbsubtitle(int fd, unsigned char *data, size_t data_len,
|
||||
iov[1].iov_base = data;
|
||||
iov[1].iov_len = data_len;
|
||||
len = writev(fd, iov, 2);
|
||||
if (len != (int)(iov[0].iov_len + iov[1].iov_len)) {
|
||||
if (len != (int) (iov[0].iov_len + iov[1].iov_len)) {
|
||||
// writing to pipe failed, clear it.
|
||||
char buf[65536];
|
||||
while(0 < read(fd, buf, sizeof(buf)));
|
||||
while (0 < read(fd, buf, sizeof(buf)));
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static int Write(void *_context __attribute__((unused)), void* _out)
|
||||
static int Write(void *_context __attribute__ ((unused)), void *_out)
|
||||
{
|
||||
AudioVideoOut_t *out = (AudioVideoOut_t*) _out;
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
int res = 0;
|
||||
unsigned char dvbsubtitle;
|
||||
unsigned char teletext;
|
||||
AudioVideoOut_t *out = (AudioVideoOut_t *) _out;
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
int res = 0;
|
||||
unsigned char dvbsubtitle;
|
||||
unsigned char teletext;
|
||||
|
||||
if (out == NULL)
|
||||
{
|
||||
pipe_err("null pointer passed\n");
|
||||
return cERR_PIPE_ERROR;
|
||||
if (out == NULL) {
|
||||
pipe_err("null pointer passed\n");
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
dvbsubtitle = !strcmp("dvbsubtitle", out->type);
|
||||
teletext = !strcmp("teletext", out->type);
|
||||
|
||||
pipe_printf(20, "DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n",
|
||||
out->len, out->extralen, out->pts, out->frameRate);
|
||||
|
||||
pipe_printf(20,
|
||||
"DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n",
|
||||
out->len, out->extralen, out->pts, out->frameRate);
|
||||
pipe_printf(20, "v%d a%d\n", dvbsubtitle, teletext);
|
||||
|
||||
if (dvbsubtitle) {
|
||||
res = writePESDataDvbsubtitle(dvbsubtitlefd, out->data, out->len, out->pts);
|
||||
res =
|
||||
writePESDataDvbsubtitle(dvbsubtitlefd, out->data, out->len,
|
||||
out->pts);
|
||||
|
||||
if (res <= 0)
|
||||
{
|
||||
ret = cERR_PIPE_ERROR;
|
||||
}
|
||||
if (res <= 0) {
|
||||
ret = cERR_PIPE_ERROR;
|
||||
}
|
||||
} else if (teletext) {
|
||||
res = writePESDataTeletext(teletextfd, out->data, out->len);
|
||||
|
||||
if (res <= 0)
|
||||
{
|
||||
ret = cERR_PIPE_ERROR;
|
||||
}
|
||||
if (res <= 0) {
|
||||
ret = cERR_PIPE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int reset(Context_t *context __attribute__((unused)))
|
||||
static int reset(Context_t * context __attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int Command(void *_context, OutputCmd_t command, void * argument) {
|
||||
Context_t* context = (Context_t*) _context;
|
||||
static int Command(void *_context, OutputCmd_t command, void *argument)
|
||||
{
|
||||
Context_t *context = (Context_t *) _context;
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
|
||||
pipe_printf(50, "Command %d\n", command);
|
||||
|
||||
switch(command) {
|
||||
case OUTPUT_OPEN: {
|
||||
ret = PipeOpen(context, (char*)argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLOSE: {
|
||||
ret = PipeClose(context, (char*)argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PLAY: { // 4
|
||||
ret = PipePlay(context, (char*)argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_STOP: {
|
||||
reset(context);
|
||||
ret = PipeStop(context, (char*)argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FLUSH: {
|
||||
ret = PipeFlush(context, (char*)argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLEAR: {
|
||||
ret = PipeClear(context, (char*)argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SWITCH: {
|
||||
ret = PipeSwitch(context, (char*)argument);
|
||||
break;
|
||||
}
|
||||
switch (command) {
|
||||
case OUTPUT_OPEN:{
|
||||
ret = PipeOpen(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLOSE:{
|
||||
ret = PipeClose(context, (char *) argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PLAY:{ // 4
|
||||
ret = PipePlay(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_STOP:{
|
||||
reset(context);
|
||||
ret = PipeStop(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FLUSH:{
|
||||
ret = PipeFlush(context, (char *) argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLEAR:{
|
||||
ret = PipeClear(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SWITCH:{
|
||||
ret = PipeSwitch(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pipe_err("ContainerCmd %d not supported!\n", command);
|
||||
ret = cERR_PIPE_ERROR;
|
||||
break;
|
||||
pipe_err("ContainerCmd %d not supported!\n", command);
|
||||
ret = cERR_PIPE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
pipe_printf(50, "exiting with value %d\n", ret);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -189,11 +189,12 @@ else
|
||||
|
||||
*/
|
||||
|
||||
static unsigned char DefaultAACHeader[] = {
|
||||
static unsigned char DefaultAACHeader[] = {
|
||||
0xff,
|
||||
0xf1,
|
||||
/*0x00, 0x00*/0x50, //((Profile & 0x03) << 6) | (SampleIndex << 2) | ((Channels >> 2) & 0x01);s
|
||||
0x80, //(Channels & 0x03) << 6;
|
||||
/*0x00, 0x00 */ 0x50,
|
||||
//((Profile & 0x03) << 6) | (SampleIndex << 2) | ((Channels >> 2) & 0x01);s
|
||||
0x80, //(Channels & 0x03) << 6;
|
||||
0x00,
|
||||
0x1f,
|
||||
0xfc
|
||||
@@ -211,51 +212,48 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char ExtraData[AAC_HEADER_LENGTH];
|
||||
unsigned int PacketLength;
|
||||
unsigned int PacketLength;
|
||||
|
||||
aac_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
aac_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
aac_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
aac_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
PacketLength = call->len + AAC_HEADER_LENGTH;
|
||||
PacketLength = call->len + AAC_HEADER_LENGTH;
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
aac_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
aac_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
aac_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
aac_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->private_data == NULL)
|
||||
{
|
||||
aac_printf(10, "private_data = NULL\n");
|
||||
memcpy (ExtraData, DefaultAACHeader, AAC_HEADER_LENGTH);
|
||||
}
|
||||
else
|
||||
memcpy (ExtraData, call->private_data, AAC_HEADER_LENGTH);
|
||||
if (call->private_data == NULL) {
|
||||
aac_printf(10, "private_data = NULL\n");
|
||||
memcpy(ExtraData, DefaultAACHeader, AAC_HEADER_LENGTH);
|
||||
} else
|
||||
memcpy(ExtraData, call->private_data, AAC_HEADER_LENGTH);
|
||||
|
||||
ExtraData[3] |= (PacketLength >> 11) & 0x3;
|
||||
ExtraData[4] = (PacketLength >> 3) & 0xff;
|
||||
ExtraData[5] |= (PacketLength << 5) & 0xe0;
|
||||
ExtraData[3] |= (PacketLength >> 11) & 0x3;
|
||||
ExtraData[4] = (PacketLength >> 3) & 0xff;
|
||||
ExtraData[5] |= (PacketLength << 5) & 0xe0;
|
||||
|
||||
unsigned int HeaderLength = InsertPesHeader (PesHeader, PacketLength, AAC_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
unsigned int HeaderLength =
|
||||
InsertPesHeader(PesHeader, PacketLength, AAC_AUDIO_PES_START_CODE,
|
||||
call->Pts, 0);
|
||||
|
||||
struct iovec iov[3];
|
||||
iov[0].iov_base = PesHeader;
|
||||
|
@@ -91,38 +91,37 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
ac3_printf(10, "\n");
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
ac3_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
ac3_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ac3_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
ac3_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
ac3_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
ac3_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
ac3_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct iovec iov[2];
|
||||
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, PRIVATE_STREAM_1_PES_START_CODE, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len,
|
||||
PRIVATE_STREAM_1_PES_START_CODE, call->Pts, 0);
|
||||
iov[1].iov_base = call->data;
|
||||
iov[1].iov_len = call->len;
|
||||
|
||||
|
@@ -91,36 +91,34 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char FakeHeaders[64]; // 64bytes should be enough to make the fake headers
|
||||
unsigned int FakeHeaderLength;
|
||||
unsigned char Version = 5;
|
||||
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
unsigned int usecPerFrame = 41708; /* Hellmaster1024: default value */
|
||||
BitPacker_t ld = {FakeHeaders, 0, 32};
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char FakeHeaders[64]; // 64bytes should be enough to make the fake headers
|
||||
unsigned int FakeHeaderLength;
|
||||
unsigned char Version = 5;
|
||||
unsigned int FakeStartCode =
|
||||
(Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
unsigned int usecPerFrame = 41708; /* Hellmaster1024: default value */
|
||||
BitPacker_t ld = { FakeHeaders, 0, 32 };
|
||||
|
||||
divx_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
divx_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
divx_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
divx_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
divx_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
divx_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
divx_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
divx_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
@@ -136,20 +134,22 @@ static int writeData(void* _call)
|
||||
PutBits(&ld, 0x0, 8);
|
||||
PutBits(&ld, 0x0, 8);
|
||||
*/
|
||||
PutBits(&ld, 0x1b0, 32); // startcode
|
||||
PutBits(&ld, 0, 8); // profile = reserved
|
||||
PutBits(&ld, 0x1b2, 32); // startcode (user data)
|
||||
PutBits(&ld, 0x53545443, 32); // STTC - an embedded ST timecode from an avi file
|
||||
PutBits(&ld, usecPerFrame , 32);
|
||||
PutBits(&ld, 0x1b0, 32); // startcode
|
||||
PutBits(&ld, 0, 8); // profile = reserved
|
||||
PutBits(&ld, 0x1b2, 32); // startcode (user data)
|
||||
PutBits(&ld, 0x53545443, 32); // STTC - an embedded ST timecode from an avi file
|
||||
PutBits(&ld, usecPerFrame, 32);
|
||||
// microseconds per frame
|
||||
FlushBits(&ld);
|
||||
|
||||
FakeHeaderLength = (ld.Ptr - (FakeHeaders));
|
||||
FakeHeaderLength = (ld.Ptr - (FakeHeaders));
|
||||
|
||||
struct iovec iov[4];
|
||||
int ic = 0;
|
||||
iov[ic].iov_base = PesHeader;
|
||||
iov[ic++].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode);
|
||||
iov[ic++].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len, MPEG_VIDEO_PES_START_CODE,
|
||||
call->Pts, FakeStartCode);
|
||||
iov[ic].iov_base = FakeHeaders;
|
||||
iov[ic++].iov_len = FakeHeaderLength;
|
||||
|
||||
@@ -157,7 +157,7 @@ static int writeData(void* _call)
|
||||
iov[ic].iov_base = call->private_data;
|
||||
iov[ic++].iov_len = call->private_size;
|
||||
|
||||
initialHeader = 0;
|
||||
initialHeader = 0;
|
||||
}
|
||||
iov[ic].iov_base = call->data;
|
||||
iov[ic++].iov_len = call->len;
|
||||
|
@@ -50,10 +50,10 @@
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
#define PES_AUDIO_PRIVATE_HEADER_SIZE 16 // consider maximum private header size.
|
||||
#define PES_AUDIO_PRIVATE_HEADER_SIZE 16 // consider maximum private header size.
|
||||
#define PES_AUDIO_HEADER_SIZE (32 + PES_AUDIO_PRIVATE_HEADER_SIZE)
|
||||
#define PES_AUDIO_PACKET_SIZE 2028
|
||||
#define SPDIF_AUDIO_PACKET_SIZE (1024 * sizeof(unsigned int) * 2) // stereo 32bit samples.
|
||||
#define SPDIF_AUDIO_PACKET_SIZE (1024 * sizeof(unsigned int) * 2) // stereo 32bit samples.
|
||||
|
||||
#define DTS_DEBUG
|
||||
|
||||
@@ -93,52 +93,51 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_AUDIO_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_AUDIO_HEADER_SIZE];
|
||||
|
||||
dts_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
dts_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
dts_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dts_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
dts_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
dts_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
dts_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
dts_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// #define DO_BYTESWAP
|
||||
#ifdef DO_BYTESWAP
|
||||
unsigned char *Data = (unsigned char *) malloc(call->len);
|
||||
memcpy(Data, call->data, call->len);
|
||||
|
||||
/* 16-bit byte swap all data before injecting it */
|
||||
for (i=0; i< call->len; i+=2)
|
||||
{
|
||||
unsigned char Tmp = Data[i];
|
||||
Data[i] = Data[i+1];
|
||||
Data[i+1] = Tmp;
|
||||
for (i = 0; i < call->len; i += 2) {
|
||||
unsigned char Tmp = Data[i];
|
||||
Data[i] = Data[i + 1];
|
||||
Data[i + 1] = Tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct iovec iov[2];
|
||||
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_AUDIO_PES_START_CODE/*PRIVATE_STREAM_1_PES_START_CODE*/, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len,
|
||||
MPEG_AUDIO_PES_START_CODE
|
||||
/*PRIVATE_STREAM_1_PES_START_CODE */ , call->Pts,
|
||||
0);
|
||||
#ifdef DO_BYTESPWAP
|
||||
iov[1].iov_base = Data;
|
||||
#else
|
||||
|
@@ -89,37 +89,36 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
flac_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
flac_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
flac_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
flac_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
flac_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
flac_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
flac_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
flac_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->len , MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE,
|
||||
call->Pts, 0);
|
||||
iov[1].iov_base = call->data;
|
||||
iov[1].iov_len = call->len;
|
||||
|
||||
@@ -137,7 +136,7 @@ static WriterCaps_t caps_flac = {
|
||||
"flac",
|
||||
eAudio,
|
||||
"A_FLAC",
|
||||
AUDIO_ENCODING_LPCM //AUDIO_ENCODING_FLAC
|
||||
AUDIO_ENCODING_LPCM //AUDIO_ENCODING_FLAC
|
||||
};
|
||||
|
||||
struct Writer_s WriterAudioFLAC = {
|
||||
|
@@ -95,95 +95,93 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
|
||||
static int reset()
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
int res = 0;
|
||||
int res = 0;
|
||||
|
||||
WriterFBCallData_t* call = (WriterFBCallData_t*) _call;
|
||||
WriterFBCallData_t *call = (WriterFBCallData_t *) _call;
|
||||
|
||||
fb_printf(100, "\n");
|
||||
fb_printf(100, "\n");
|
||||
|
||||
if (!call)
|
||||
{
|
||||
fb_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (!call) {
|
||||
fb_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!call->destination) {
|
||||
fb_err("frame buffer == NULL. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dst_stride = call->destStride / sizeof(uint32_t);
|
||||
int dst_delta = dst_stride - call->Width;
|
||||
uint32_t *dst = call->destination + call->y * dst_stride + call->x;
|
||||
|
||||
if (call->data) {
|
||||
int src_delta = call->Stride - call->Width;
|
||||
unsigned char *src = call->data;
|
||||
static uint32_t last_color = 0, colortable[256];
|
||||
|
||||
if (last_color != call->color) {
|
||||
// call->color is rgba, our spark frame buffer is argb
|
||||
uint32_t c = call->color >> 8, a = 255 - (call->color & 0xff);
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
uint32_t k = (a * i) >> 8;
|
||||
colortable[i] = k ? (c | (k << 24)) : 0;
|
||||
}
|
||||
last_color = call->color;
|
||||
}
|
||||
|
||||
if (!call->destination)
|
||||
{
|
||||
fb_err("frame buffer == NULL. ignoring ...\n");
|
||||
return 0;
|
||||
fb_printf(100, "x %d\n", call->x);
|
||||
fb_printf(100, "y %d\n", call->y);
|
||||
fb_printf(100, "width %d\n", call->Width);
|
||||
fb_printf(100, "height %d\n", call->Height);
|
||||
fb_printf(100, "stride %d\n", call->Stride);
|
||||
fb_printf(100, "color 0x%.8x\n", call->color);
|
||||
fb_printf(100, "data %p\n", call->data);
|
||||
fb_printf(100, "dest %p\n", call->destination);
|
||||
fb_printf(100, "dest.stride %d\n", call->destStride);
|
||||
|
||||
unsigned char *src_final = src + call->Height * call->Width;
|
||||
for (; src < src_final; dst += dst_delta, src += src_delta) {
|
||||
u_char *src_end = src + call->Width;
|
||||
for (; src < src_end; dst++, src++) {
|
||||
uint32_t c = colortable[*src];
|
||||
if (c)
|
||||
*dst = c;
|
||||
}
|
||||
}
|
||||
|
||||
int dst_stride = call->destStride/sizeof(uint32_t);
|
||||
int dst_delta = dst_stride - call->Width;
|
||||
uint32_t *dst = call->destination + call->y * dst_stride + call->x;
|
||||
|
||||
if (call->data)
|
||||
{
|
||||
int src_delta = call->Stride - call->Width;
|
||||
unsigned char *src = call->data;
|
||||
static uint32_t last_color = 0, colortable[256];
|
||||
|
||||
if (last_color != call->color) {
|
||||
// call->color is rgba, our spark frame buffer is argb
|
||||
uint32_t c = call->color >> 8, a = 255 - (call->color & 0xff);
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
uint32_t k = (a * i) >> 8;
|
||||
colortable[i] = k ? (c | (k << 24)) : 0;
|
||||
}
|
||||
last_color = call->color;
|
||||
}
|
||||
|
||||
fb_printf(100, "x %d\n", call->x);
|
||||
fb_printf(100, "y %d\n", call->y);
|
||||
fb_printf(100, "width %d\n", call->Width);
|
||||
fb_printf(100, "height %d\n", call->Height);
|
||||
fb_printf(100, "stride %d\n", call->Stride);
|
||||
fb_printf(100, "color 0x%.8x\n", call->color);
|
||||
fb_printf(100, "data %p\n", call->data);
|
||||
fb_printf(100, "dest %p\n", call->destination);
|
||||
fb_printf(100, "dest.stride %d\n", call->destStride);
|
||||
|
||||
unsigned char *src_final = src + call->Height * call->Width;
|
||||
for (; src < src_final; dst += dst_delta, src += src_delta) {
|
||||
u_char *src_end = src + call->Width;
|
||||
for (; src < src_end; dst++, src++) {
|
||||
uint32_t c = colortable[*src];
|
||||
if (c)
|
||||
*dst = c;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uint32_t *dst_final = dst + call->Width + call->Height * dst_stride;
|
||||
for (; dst < dst_final; dst += dst_delta) {
|
||||
uint32_t *dst_end = dst + call->Width;
|
||||
for (; dst < dst_end; dst++)
|
||||
*dst = 0;
|
||||
}
|
||||
} else {
|
||||
uint32_t *dst_final =
|
||||
dst + call->Width + call->Height * dst_stride;
|
||||
for (; dst < dst_final; dst += dst_delta) {
|
||||
uint32_t *dst_end = dst + call->Width;
|
||||
for (; dst < dst_end; dst++)
|
||||
*dst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fb_printf(100, "< %d\n", res);
|
||||
return res;
|
||||
fb_printf(100, "< %d\n", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ***************************** */
|
||||
/* Writer Definition */
|
||||
/* ***************************** */
|
||||
static WriterCaps_t caps = {
|
||||
"framebuffer",
|
||||
eGfx,
|
||||
"framebuffer",
|
||||
0
|
||||
"framebuffer",
|
||||
eGfx,
|
||||
"framebuffer",
|
||||
0
|
||||
};
|
||||
|
||||
struct Writer_s WriterFramebuffer = {
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps
|
||||
};
|
||||
|
@@ -89,47 +89,49 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
int len = 0;
|
||||
|
||||
h263_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
h263_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
h263_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
h263_printf(10, "VideoPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
h263_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
h263_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
h263_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
h263_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HeaderLength = InsertPesHeader(PesHeader, call->len, H263_VIDEO_PES_START_CODE, call->Pts,0);
|
||||
int HeaderLength =
|
||||
InsertPesHeader(PesHeader, call->len, H263_VIDEO_PES_START_CODE,
|
||||
call->Pts, 0);
|
||||
|
||||
int PrivateHeaderLength = InsertVideoPrivateDataHeader (&PesHeader[HeaderLength], call->len);
|
||||
int PrivateHeaderLength =
|
||||
InsertVideoPrivateDataHeader(&PesHeader[HeaderLength], call->len);
|
||||
|
||||
int PesLength = PesHeader[PES_LENGTH_BYTE_0] + (PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
|
||||
int PesLength =
|
||||
PesHeader[PES_LENGTH_BYTE_0] +
|
||||
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
|
||||
|
||||
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
|
||||
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] += PrivateHeaderLength;
|
||||
PesHeader[PES_FLAGS_BYTE] |= PES_EXTENSION_DATA_PRESENT;
|
||||
PesHeader[PES_FLAGS_BYTE] |= PES_EXTENSION_DATA_PRESENT;
|
||||
|
||||
HeaderLength += PrivateHeaderLength;
|
||||
HeaderLength += PrivateHeaderLength;
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
|
@@ -75,24 +75,24 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
typedef struct avcC_s
|
||||
{
|
||||
unsigned char Version; /* configurationVersion */
|
||||
unsigned char Profile; /* AVCProfileIndication */
|
||||
unsigned char Compatibility; /* profile_compatibility */
|
||||
unsigned char Level; /* AVCLevelIndication */
|
||||
unsigned char NalLengthMinusOne; /* held in bottom two bits */
|
||||
unsigned char NumParamSets; /* held in bottom 5 bits */
|
||||
unsigned char Params[1]; /* {length,params}{length,params}...sequence then picture*/
|
||||
typedef struct avcC_s {
|
||||
unsigned char Version; /* configurationVersion */
|
||||
unsigned char Profile; /* AVCProfileIndication */
|
||||
unsigned char Compatibility; /* profile_compatibility */
|
||||
unsigned char Level; /* AVCLevelIndication */
|
||||
unsigned char NalLengthMinusOne; /* held in bottom two bits */
|
||||
unsigned char NumParamSets; /* held in bottom 5 bits */
|
||||
unsigned char Params[1]; /* {length,params}{length,params}...sequence then picture */
|
||||
} avcC_t;
|
||||
|
||||
|
||||
/* ***************************** */
|
||||
/* Varaibles */
|
||||
/* ***************************** */
|
||||
const unsigned char Head[] = {0, 0, 0, 1};
|
||||
const unsigned char Head[] = { 0, 0, 0, 1 };
|
||||
|
||||
static int initialHeader = 1;
|
||||
static unsigned int NalLengthBytes = 1;
|
||||
static unsigned int NalLengthBytes = 1;
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
@@ -108,271 +108,309 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned long long int VideoPts;
|
||||
unsigned int TimeDelta;
|
||||
unsigned int TimeScale;
|
||||
int len = 0;
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned long long int VideoPts;
|
||||
unsigned int TimeDelta;
|
||||
unsigned int TimeScale;
|
||||
int len = 0;
|
||||
int ic = 0;
|
||||
struct iovec iov[128];
|
||||
h264_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
h264_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
h264_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
TimeDelta = call->FrameRate;
|
||||
TimeScale = call->FrameScale;
|
||||
VideoPts = call->Pts;
|
||||
VideoPts = call->Pts;
|
||||
|
||||
h264_printf(10, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta, TimeScale);
|
||||
h264_printf(10, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta,
|
||||
TimeScale);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
h264_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
h264_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
h264_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
h264_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))
|
||||
{
|
||||
if ((call->len > 3)
|
||||
&&
|
||||
((call->data[0] == 0x00 && call->data[1] == 0x00
|
||||
&& call->data[2] == 0x00 && call->data[3] == 0x01)
|
||||
|| (call->data[0] == 0xff && call->data[1] == 0xff
|
||||
&& call->data[2] == 0xff && call->data[3] == 0xff))) {
|
||||
unsigned int PacketLength = 0;
|
||||
unsigned int FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
unsigned int FakeStartCode =
|
||||
(call->Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
if (initialHeader) {
|
||||
initialHeader = 0;
|
||||
iov[ic].iov_base = call->private_data;
|
||||
iov[ic++].iov_len = call->private_size;
|
||||
PacketLength += call->private_size;
|
||||
initialHeader = 0;
|
||||
iov[ic].iov_base = call->private_data;
|
||||
iov[ic++].iov_len = call->private_size;
|
||||
PacketLength += call->private_size;
|
||||
}
|
||||
iov[ic].iov_base = call->data;
|
||||
iov[ic++].iov_len = call->len;
|
||||
PacketLength += call->len;
|
||||
/*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
|
||||
data is available. The content of this byte does not matter. It will be ignored
|
||||
by the player */
|
||||
/*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
|
||||
data is available. The content of this byte does not matter. It will be ignored
|
||||
by the player */
|
||||
iov[ic].iov_base = "";
|
||||
iov[ic++].iov_len = 1;
|
||||
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, PacketLength,
|
||||
MPEG_VIDEO_PES_START_CODE, call->Pts,
|
||||
FakeStartCode);
|
||||
return writev(call->fd, iov, ic);
|
||||
}
|
||||
|
||||
if (initialHeader)
|
||||
{
|
||||
avcC_t* avcCHeader = (avcC_t*)call->private_data;
|
||||
unsigned int i;
|
||||
unsigned int ParamSets;
|
||||
unsigned int ParamOffset;
|
||||
unsigned int InitialHeaderLength = 0;
|
||||
unsigned int ParametersLength;
|
||||
if (initialHeader) {
|
||||
avcC_t *avcCHeader = (avcC_t *) call->private_data;
|
||||
unsigned int i;
|
||||
unsigned int ParamSets;
|
||||
unsigned int ParamOffset;
|
||||
unsigned int InitialHeaderLength = 0;
|
||||
unsigned int ParametersLength;
|
||||
|
||||
if (avcCHeader == NULL) {
|
||||
h264_err("private_data NULL\n");
|
||||
return -1;
|
||||
}
|
||||
if (avcCHeader == NULL) {
|
||||
h264_err("private_data NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avcCHeader->Version != 1)
|
||||
h264_err("Error unknown avcC version (%x). Expect problems.\n", avcCHeader->Version);
|
||||
if (avcCHeader->Version != 1)
|
||||
h264_err("Error unknown avcC version (%x). Expect problems.\n",
|
||||
avcCHeader->Version);
|
||||
|
||||
ParametersLength = 0;
|
||||
ParametersLength = 0;
|
||||
|
||||
unsigned char HeaderData[19];
|
||||
HeaderData[ParametersLength++] = 0x00; // Start code
|
||||
HeaderData[ParametersLength++] = 0x00;
|
||||
HeaderData[ParametersLength++] = 0x01;
|
||||
HeaderData[ParametersLength++] = NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
|
||||
// Container message version - changes when/if we vary the format of the message
|
||||
HeaderData[ParametersLength++] = CONTAINER_PARAMETERS_VERSION;
|
||||
HeaderData[ParametersLength++] = 0xff; // Field separator
|
||||
unsigned char HeaderData[19];
|
||||
HeaderData[ParametersLength++] = 0x00; // Start code
|
||||
HeaderData[ParametersLength++] = 0x00;
|
||||
HeaderData[ParametersLength++] = 0x01;
|
||||
HeaderData[ParametersLength++] =
|
||||
NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
|
||||
// Container message version - changes when/if we vary the format of the message
|
||||
HeaderData[ParametersLength++] = CONTAINER_PARAMETERS_VERSION;
|
||||
HeaderData[ParametersLength++] = 0xff; // Field separator
|
||||
|
||||
if( TimeDelta == 0xffffffff )
|
||||
TimeDelta = (TimeScale > 1000) ? 1001 : 1;
|
||||
if (TimeDelta == 0xffffffff)
|
||||
TimeDelta = (TimeScale > 1000) ? 1001 : 1;
|
||||
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 24) & 0xff; // Output the timescale
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 16) & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 8) & 0xff;
|
||||
HeaderData[ParametersLength++] = TimeScale & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 24) & 0xff; // Output the timescale
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 16) & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = (TimeScale >> 8) & 0xff;
|
||||
HeaderData[ParametersLength++] = TimeScale & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 24) & 0xff; // Output frame period
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 16) & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 8) & 0xff;
|
||||
HeaderData[ParametersLength++] = TimeDelta & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = 0x80; // Rsbp trailing bits
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 24) & 0xff; // Output frame period
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 16) & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = (TimeDelta >> 8) & 0xff;
|
||||
HeaderData[ParametersLength++] = TimeDelta & 0xff;
|
||||
HeaderData[ParametersLength++] = 0xff;
|
||||
HeaderData[ParametersLength++] = 0x80; // Rsbp trailing bits
|
||||
|
||||
assert(ParametersLength <= sizeof(HeaderData));
|
||||
|
||||
ic = 0;
|
||||
iov[ic].iov_base = PesHeader;
|
||||
iov[ic++].iov_len = InsertPesHeader (PesHeader, ParametersLength, MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
iov[ic++].iov_len =
|
||||
InsertPesHeader(PesHeader, ParametersLength,
|
||||
MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
|
||||
0);
|
||||
iov[ic].iov_base = HeaderData;
|
||||
iov[ic++].iov_len = ParametersLength;
|
||||
len = writev(call->fd, iov, ic);
|
||||
if (len < 0)
|
||||
return len;
|
||||
return len;
|
||||
|
||||
NalLengthBytes = (avcCHeader->NalLengthMinusOne & 0x03) + 1;
|
||||
ParamSets = avcCHeader->NumParamSets & 0x1f;
|
||||
NalLengthBytes = (avcCHeader->NalLengthMinusOne & 0x03) + 1;
|
||||
ParamSets = avcCHeader->NumParamSets & 0x1f;
|
||||
|
||||
h264_printf(20, "avcC contents:\n");
|
||||
h264_printf(20, " version: %d\n", avcCHeader->Version);
|
||||
h264_printf(20, " profile: %d\n", avcCHeader->Profile);
|
||||
h264_printf(20, " profile compatibility: %d\n", avcCHeader->Compatibility);
|
||||
h264_printf(20, " level: %d\n", avcCHeader->Level);
|
||||
h264_printf(20, " nal length bytes: %d\n", NalLengthBytes);
|
||||
h264_printf(20, " number of sequence param sets: %d\n", ParamSets);
|
||||
h264_printf(20, "avcC contents:\n");
|
||||
h264_printf(20, " version: %d\n",
|
||||
avcCHeader->Version);
|
||||
h264_printf(20, " profile: %d\n",
|
||||
avcCHeader->Profile);
|
||||
h264_printf(20, " profile compatibility: %d\n",
|
||||
avcCHeader->Compatibility);
|
||||
h264_printf(20, " level: %d\n",
|
||||
avcCHeader->Level);
|
||||
h264_printf(20, " nal length bytes: %d\n",
|
||||
NalLengthBytes);
|
||||
h264_printf(20, " number of sequence param sets: %d\n",
|
||||
ParamSets);
|
||||
|
||||
ParamOffset = 0;
|
||||
ParamOffset = 0;
|
||||
ic = 0;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
for (i = 0; i < ParamSets; i++) {
|
||||
unsigned int PsLength = (avcCHeader->Params[ParamOffset] << 8) + avcCHeader->Params[ParamOffset+1];
|
||||
for (i = 0; i < ParamSets; i++) {
|
||||
unsigned int PsLength =
|
||||
(avcCHeader->Params[ParamOffset] << 8) +
|
||||
avcCHeader->Params[ParamOffset + 1];
|
||||
|
||||
h264_printf(20, " sps %d has length %d\n", i, PsLength);
|
||||
|
||||
iov[ic].iov_base = (char *)Head;
|
||||
iov[ic++].iov_len = sizeof(Head);
|
||||
InitialHeaderLength += sizeof(Head);
|
||||
iov[ic].iov_base = &avcCHeader->Params[ParamOffset+2];
|
||||
iov[ic++].iov_len = PsLength;
|
||||
InitialHeaderLength += PsLength;
|
||||
ParamOffset += PsLength+2;
|
||||
}
|
||||
|
||||
ParamSets = avcCHeader->Params[ParamOffset];
|
||||
|
||||
h264_printf(20, " number of picture param sets: %d\n", ParamSets);
|
||||
|
||||
ParamOffset++;
|
||||
for (i = 0; i < ParamSets; i++) {
|
||||
unsigned int PsLength = (avcCHeader->Params[ParamOffset] << 8) + avcCHeader->Params[ParamOffset+1];
|
||||
|
||||
h264_printf (20, " pps %d has length %d\n", i, PsLength);
|
||||
h264_printf(20, " sps %d has length %d\n", i,
|
||||
PsLength);
|
||||
|
||||
iov[ic].iov_base = (char *) Head;
|
||||
iov[ic++].iov_len = sizeof(Head);
|
||||
InitialHeaderLength += sizeof(Head);
|
||||
iov[ic].iov_base = &avcCHeader->Params[ParamOffset+2];
|
||||
InitialHeaderLength += sizeof(Head);
|
||||
iov[ic].iov_base = &avcCHeader->Params[ParamOffset + 2];
|
||||
iov[ic++].iov_len = PsLength;
|
||||
InitialHeaderLength += PsLength;
|
||||
ParamOffset += PsLength+2;
|
||||
}
|
||||
InitialHeaderLength += PsLength;
|
||||
ParamOffset += PsLength + 2;
|
||||
}
|
||||
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, InitialHeaderLength, MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
ParamSets = avcCHeader->Params[ParamOffset];
|
||||
|
||||
h264_printf(20, " number of picture param sets: %d\n",
|
||||
ParamSets);
|
||||
|
||||
ParamOffset++;
|
||||
for (i = 0; i < ParamSets; i++) {
|
||||
unsigned int PsLength =
|
||||
(avcCHeader->Params[ParamOffset] << 8) +
|
||||
avcCHeader->Params[ParamOffset + 1];
|
||||
|
||||
h264_printf(20, " pps %d has length %d\n", i,
|
||||
PsLength);
|
||||
|
||||
iov[ic].iov_base = (char *) Head;
|
||||
iov[ic++].iov_len = sizeof(Head);
|
||||
InitialHeaderLength += sizeof(Head);
|
||||
iov[ic].iov_base = &avcCHeader->Params[ParamOffset + 2];
|
||||
iov[ic++].iov_len = PsLength;
|
||||
InitialHeaderLength += PsLength;
|
||||
ParamOffset += PsLength + 2;
|
||||
}
|
||||
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, InitialHeaderLength,
|
||||
MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
|
||||
0);
|
||||
ssize_t l = writev(call->fd, iov, ic);
|
||||
if (l < 0)
|
||||
return l;
|
||||
return l;
|
||||
len += l;
|
||||
|
||||
initialHeader = 0;
|
||||
initialHeader = 0;
|
||||
}
|
||||
|
||||
unsigned int SampleSize = call->len;
|
||||
unsigned int NalStart = 0;
|
||||
unsigned int SampleSize = call->len;
|
||||
unsigned int NalStart = 0;
|
||||
unsigned int VideoPosition = 0;
|
||||
|
||||
do {
|
||||
unsigned int NalLength;
|
||||
unsigned char NalData[4];
|
||||
int NalPresent = 1;
|
||||
unsigned int NalLength;
|
||||
unsigned char NalData[4];
|
||||
int NalPresent = 1;
|
||||
|
||||
memcpy (NalData, call->data + VideoPosition, NalLengthBytes);
|
||||
VideoPosition += NalLengthBytes;
|
||||
NalStart += NalLengthBytes;
|
||||
switch(NalLengthBytes) {
|
||||
case 1: NalLength = (NalData[0]); break;
|
||||
case 2: NalLength = (NalData[0] << 8) | (NalData[1]); break;
|
||||
case 3: NalLength = (NalData[0] << 16) | (NalData[1] << 8) | (NalData[2]); break;
|
||||
default: NalLength = (NalData[0] << 24) | (NalData[1] << 16) | (NalData[2] << 8) | (NalData[3]); break;
|
||||
}
|
||||
memcpy(NalData, call->data + VideoPosition, NalLengthBytes);
|
||||
VideoPosition += NalLengthBytes;
|
||||
NalStart += NalLengthBytes;
|
||||
switch (NalLengthBytes) {
|
||||
case 1:
|
||||
NalLength = (NalData[0]);
|
||||
break;
|
||||
case 2:
|
||||
NalLength = (NalData[0] << 8) | (NalData[1]);
|
||||
break;
|
||||
case 3:
|
||||
NalLength =
|
||||
(NalData[0] << 16) | (NalData[1] << 8) | (NalData[2]);
|
||||
break;
|
||||
default:
|
||||
NalLength =
|
||||
(NalData[0] << 24) | (NalData[1] << 16) | (NalData[2] << 8)
|
||||
| (NalData[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
h264_printf(20, "NalStart = %u + NalLength = %u > SampleSize = %u\n", NalStart, NalLength, SampleSize);
|
||||
h264_printf(20,
|
||||
"NalStart = %u + NalLength = %u > SampleSize = %u\n",
|
||||
NalStart, NalLength, SampleSize);
|
||||
|
||||
if (NalStart + NalLength > SampleSize) {
|
||||
h264_printf(20, "nal length past end of buffer - size %u frame offset %u left %u\n",
|
||||
NalLength, NalStart , SampleSize - NalStart );
|
||||
if (NalStart + NalLength > SampleSize) {
|
||||
h264_printf(20,
|
||||
"nal length past end of buffer - size %u frame offset %u left %u\n",
|
||||
NalLength, NalStart, SampleSize - NalStart);
|
||||
|
||||
NalStart = SampleSize;
|
||||
} else {
|
||||
NalStart += NalLength;
|
||||
ic = 0;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
NalStart = SampleSize;
|
||||
} else {
|
||||
NalStart += NalLength;
|
||||
ic = 0;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
|
||||
if (NalPresent) {
|
||||
NalPresent = 0;
|
||||
iov[ic].iov_base = (char *)Head;
|
||||
iov[ic++].iov_len = sizeof(Head);
|
||||
}
|
||||
if (NalPresent) {
|
||||
NalPresent = 0;
|
||||
iov[ic].iov_base = (char *) Head;
|
||||
iov[ic++].iov_len = sizeof(Head);
|
||||
}
|
||||
|
||||
iov[ic].iov_base = call->data + VideoPosition;
|
||||
iov[ic++].iov_len = NalLength;
|
||||
VideoPosition += NalLength;
|
||||
iov[ic].iov_base = call->data + VideoPosition;
|
||||
iov[ic++].iov_len = NalLength;
|
||||
VideoPosition += NalLength;
|
||||
|
||||
h264_printf (20, " pts=%llu\n", VideoPts);
|
||||
h264_printf(20, " pts=%llu\n", VideoPts);
|
||||
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, NalLength, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
|
||||
ssize_t l = writev(call->fd, iov, ic);
|
||||
if (l < 0)
|
||||
return l;
|
||||
len += l;
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, NalLength,
|
||||
MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
|
||||
ssize_t l = writev(call->fd, iov, ic);
|
||||
if (l < 0)
|
||||
return l;
|
||||
len += l;
|
||||
|
||||
VideoPts = INVALID_PTS_VALUE;
|
||||
}
|
||||
VideoPts = INVALID_PTS_VALUE;
|
||||
}
|
||||
} while (NalStart < SampleSize);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
h264_err("error writing data errno = %d\n", errno);
|
||||
h264_err("%s\n", strerror(errno));
|
||||
if (len < 0) {
|
||||
h264_err("error writing data errno = %d\n", errno);
|
||||
h264_err("%s\n", strerror(errno));
|
||||
}
|
||||
|
||||
h264_printf (10, "< len %d\n", len);
|
||||
h264_printf(10, "< len %d\n", len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int writeReverseData(void* _call)
|
||||
static int writeReverseData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
h264_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
h264_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
h264_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
h264_printf(10, "VideoPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
h264_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
h264_err("NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
h264_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
h264_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ***************************** */
|
||||
/* Writer Definition */
|
||||
/* ***************************** */
|
||||
|
@@ -72,35 +72,33 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
||||
|
||||
#ifdef DEBUG_PUTBITS
|
||||
if (ld->debug)
|
||||
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n", code, length, bit_buf, bit_left);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n",
|
||||
code, length, bit_buf, bit_left);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
|
||||
if (length < bit_left)
|
||||
{
|
||||
/* fits into current buffer */
|
||||
bit_buf = (bit_buf << length) | code;
|
||||
bit_left -= length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* doesn't fit */
|
||||
bit_buf <<= bit_left;
|
||||
bit_buf |= code >> (length - bit_left);
|
||||
ld->Ptr[0] = (char)(bit_buf >> 24);
|
||||
ld->Ptr[1] = (char)(bit_buf >> 16);
|
||||
ld->Ptr[2] = (char)(bit_buf >> 8);
|
||||
ld->Ptr[3] = (char)bit_buf;
|
||||
ld->Ptr += 4;
|
||||
length -= bit_left;
|
||||
bit_buf = code & ((1 << length) - 1);
|
||||
bit_left = 32 - length;
|
||||
bit_buf = code;
|
||||
if (length < bit_left) {
|
||||
/* fits into current buffer */
|
||||
bit_buf = (bit_buf << length) | code;
|
||||
bit_left -= length;
|
||||
} else {
|
||||
/* doesn't fit */
|
||||
bit_buf <<= bit_left;
|
||||
bit_buf |= code >> (length - bit_left);
|
||||
ld->Ptr[0] = (char) (bit_buf >> 24);
|
||||
ld->Ptr[1] = (char) (bit_buf >> 16);
|
||||
ld->Ptr[2] = (char) (bit_buf >> 8);
|
||||
ld->Ptr[3] = (char) bit_buf;
|
||||
ld->Ptr += 4;
|
||||
length -= bit_left;
|
||||
bit_buf = code & ((1 << length) - 1);
|
||||
bit_left = 32 - length;
|
||||
bit_buf = code;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PUTBITS
|
||||
if (ld->debug)
|
||||
dprintf("bit_left = %d, bit_buf = 0x%x\n", bit_left, bit_buf);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
dprintf("bit_left = %d, bit_buf = 0x%x\n", bit_left, bit_buf);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
|
||||
/* writeback */
|
||||
ld->BitBuffer = bit_buf;
|
||||
@@ -110,15 +108,14 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
||||
void FlushBits(BitPacker_t * ld)
|
||||
{
|
||||
ld->BitBuffer <<= ld->Remaining;
|
||||
while (ld->Remaining < 32)
|
||||
{
|
||||
while (ld->Remaining < 32) {
|
||||
#ifdef DEBUG_PUTBITS
|
||||
if (ld->debug)
|
||||
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
*ld->Ptr++ = ld->BitBuffer >> 24;
|
||||
ld->BitBuffer <<= 8;
|
||||
ld->Remaining += 8;
|
||||
if (ld->debug)
|
||||
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);
|
||||
#endif /* DEBUG_PUTBITS */
|
||||
*ld->Ptr++ = ld->BitBuffer >> 24;
|
||||
ld->BitBuffer <<= 8;
|
||||
ld->Remaining += 8;
|
||||
}
|
||||
ld->Remaining = 32;
|
||||
ld->BitBuffer = 0;
|
||||
|
@@ -89,37 +89,36 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
mp3_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
mp3_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
mp3_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mp3_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
mp3_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
mp3_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
mp3_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
mp3_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->len , MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE,
|
||||
call->Pts, 0);
|
||||
iov[1].iov_base = call->data;
|
||||
iov[1].iov_len = call->len;
|
||||
|
||||
|
@@ -90,59 +90,58 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
int len = 0;
|
||||
unsigned int Position = 0;
|
||||
|
||||
mpeg2_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
mpeg2_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
mpeg2_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mpeg2_printf(10, "VideoPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
mpeg2_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
mpeg2_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
mpeg2_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
mpeg2_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(Position < call->len) {
|
||||
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
while (Position < call->len) {
|
||||
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
|
||||
mpeg2_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
mpeg2_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
|
||||
PacketLength, Remaining, Position);
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, PacketLength, 0xe0, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, PacketLength, 0xe0, call->Pts, 0);
|
||||
iov[1].iov_base = call->data + Position;
|
||||
iov[1].iov_len = PacketLength;
|
||||
|
||||
ssize_t l = writev(call->fd, iov, 2);
|
||||
ssize_t l = writev(call->fd, iov, 2);
|
||||
if (l < 0) {
|
||||
len = l;
|
||||
break;
|
||||
len = l;
|
||||
break;
|
||||
}
|
||||
len += l;
|
||||
|
||||
Position += PacketLength;
|
||||
call->Pts = INVALID_PTS_VALUE;
|
||||
Position += PacketLength;
|
||||
call->Pts = INVALID_PTS_VALUE;
|
||||
}
|
||||
|
||||
mpeg2_printf(10, "< len %d\n", len);
|
||||
|
@@ -83,18 +83,18 @@ static unsigned int SubFrameLen = 0;
|
||||
static unsigned int SubFramesPerPES = 0;
|
||||
|
||||
// reference: search for TypeLpcmDVDAudio in player/frame_parser/frame_parser_audio_lpcm.cpp
|
||||
static const unsigned char clpcm_prv[14] = { 0xA0, //sub_stream_id
|
||||
0, 0, //resvd and UPC_EAN_ISRC stuff, unused
|
||||
0x0A, //private header length
|
||||
0, 9, //first_access_unit_pointer
|
||||
0x00, //emph,rsvd,stereo,downmix
|
||||
0x0F, //quantisation word length 1,2
|
||||
0x0F, //audio sampling freqency 1,2
|
||||
0, //resvd, multi channel type
|
||||
0, //bit shift on channel GR2, assignment
|
||||
0x80, //dynamic range control
|
||||
0, 0 //resvd for copyright management
|
||||
};
|
||||
static const unsigned char clpcm_prv[14] = { 0xA0, //sub_stream_id
|
||||
0, 0, //resvd and UPC_EAN_ISRC stuff, unused
|
||||
0x0A, //private header length
|
||||
0, 9, //first_access_unit_pointer
|
||||
0x00, //emph,rsvd,stereo,downmix
|
||||
0x0F, //quantisation word length 1,2
|
||||
0x0F, //audio sampling freqency 1,2
|
||||
0, //resvd, multi channel type
|
||||
0, //bit shift on channel GR2, assignment
|
||||
0x80, //dynamic range control
|
||||
0, 0 //resvd for copyright management
|
||||
};
|
||||
|
||||
static unsigned char lpcm_prv[14];
|
||||
static unsigned char breakBuffer[8192];
|
||||
@@ -108,184 +108,199 @@ static unsigned int breakBufferFillSize = 0;
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int prepareClipPlay(int uNoOfChannels, int uSampleRate, int uBitsPerSample, int bLittleEndian __attribute__((unused)))
|
||||
static int prepareClipPlay(int uNoOfChannels, int uSampleRate,
|
||||
int uBitsPerSample, int bLittleEndian
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
printf("rate: %d ch: %d bits: %d (%d bps)\n",
|
||||
uSampleRate/*Format->dwSamplesPerSec*/,
|
||||
uNoOfChannels/*Format->wChannels*/,
|
||||
uBitsPerSample/*Format->wBitsPerSample*/,
|
||||
(uBitsPerSample/*Format->wBitsPerSample*/ / 8)
|
||||
printf("rate: %d ch: %d bits: %d (%d bps)\n",
|
||||
uSampleRate /*Format->dwSamplesPerSec */ ,
|
||||
uNoOfChannels /*Format->wChannels */ ,
|
||||
uBitsPerSample /*Format->wBitsPerSample */ ,
|
||||
(uBitsPerSample /*Format->wBitsPerSample */ / 8)
|
||||
);
|
||||
|
||||
SubFrameLen = 0;
|
||||
SubFramesPerPES = 0;
|
||||
breakBufferFillSize = 0;
|
||||
SubFrameLen = 0;
|
||||
SubFramesPerPES = 0;
|
||||
breakBufferFillSize = 0;
|
||||
|
||||
memcpy(lpcm_prv, clpcm_prv, sizeof(lpcm_prv));
|
||||
memcpy(lpcm_prv, clpcm_prv, sizeof(lpcm_prv));
|
||||
|
||||
//figure out size of subframe
|
||||
//and set up sample rate
|
||||
switch(uSampleRate) {
|
||||
case 48000: SubFrameLen = 40;
|
||||
break;
|
||||
case 96000: lpcm_prv[8] |= 0x10;
|
||||
SubFrameLen = 80;
|
||||
break;
|
||||
case 192000: lpcm_prv[8] |= 0x20;
|
||||
SubFrameLen = 160;
|
||||
break;
|
||||
case 44100: lpcm_prv[8] |= 0x80;
|
||||
SubFrameLen = 40;
|
||||
break;
|
||||
case 88200: lpcm_prv[8] |= 0x90;
|
||||
SubFrameLen = 80;
|
||||
break;
|
||||
case 176400: lpcm_prv[8] |= 0xA0;
|
||||
SubFrameLen = 160;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
//figure out size of subframe
|
||||
//and set up sample rate
|
||||
switch (uSampleRate) {
|
||||
case 48000:
|
||||
SubFrameLen = 40;
|
||||
break;
|
||||
case 96000:
|
||||
lpcm_prv[8] |= 0x10;
|
||||
SubFrameLen = 80;
|
||||
break;
|
||||
case 192000:
|
||||
lpcm_prv[8] |= 0x20;
|
||||
SubFrameLen = 160;
|
||||
break;
|
||||
case 44100:
|
||||
lpcm_prv[8] |= 0x80;
|
||||
SubFrameLen = 40;
|
||||
break;
|
||||
case 88200:
|
||||
lpcm_prv[8] |= 0x90;
|
||||
SubFrameLen = 80;
|
||||
break;
|
||||
case 176400:
|
||||
lpcm_prv[8] |= 0xA0;
|
||||
SubFrameLen = 160;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SubFrameLen *= uNoOfChannels;
|
||||
SubFrameLen *= (uBitsPerSample / 8);
|
||||
SubFrameLen *= uNoOfChannels;
|
||||
SubFrameLen *= (uBitsPerSample / 8);
|
||||
|
||||
//rewrite PES size to have as many complete subframes per PES as we can
|
||||
// FIXME: PES header size was hardcoded to 18 in previous code. Actual size returned by InsertPesHeader is 14.
|
||||
SubFramesPerPES = ((2048 - 18) - sizeof(lpcm_prv))/SubFrameLen;
|
||||
SubFrameLen *= SubFramesPerPES;
|
||||
//rewrite PES size to have as many complete subframes per PES as we can
|
||||
// FIXME: PES header size was hardcoded to 18 in previous code. Actual size returned by InsertPesHeader is 14.
|
||||
SubFramesPerPES = ((2048 - 18) - sizeof(lpcm_prv)) / SubFrameLen;
|
||||
SubFrameLen *= SubFramesPerPES;
|
||||
|
||||
//set number of channels
|
||||
lpcm_prv[10] = uNoOfChannels - 1;
|
||||
//set number of channels
|
||||
lpcm_prv[10] = uNoOfChannels - 1;
|
||||
|
||||
switch(uBitsPerSample) {
|
||||
case 24:
|
||||
lpcm_prv[7] |= 0x20;
|
||||
case 16:
|
||||
break;
|
||||
default:
|
||||
printf("inappropriate bits per sample (%d) - must be 16 or 24\n",uBitsPerSample);
|
||||
return 1;
|
||||
}
|
||||
switch (uBitsPerSample) {
|
||||
case 24:
|
||||
lpcm_prv[7] |= 0x20;
|
||||
case 16:
|
||||
break;
|
||||
default:
|
||||
printf("inappropriate bits per sample (%d) - must be 16 or 24\n",
|
||||
uBitsPerSample);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int reset()
|
||||
{
|
||||
initialHeader = 1;
|
||||
return 0;
|
||||
initialHeader = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
pcm_printf(10, "\n");
|
||||
pcm_printf(10, "\n");
|
||||
|
||||
if (!call) {
|
||||
pcm_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (!call) {
|
||||
pcm_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pcm_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if (!call->data || (call->len <= 0)) {
|
||||
pcm_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0) {
|
||||
pcm_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pcmPrivateData_t *pcmPrivateData =
|
||||
(pcmPrivateData_t *) call->private_data;
|
||||
|
||||
if (initialHeader) {
|
||||
initialHeader = 0;
|
||||
prepareClipPlay(pcmPrivateData->uNoOfChannels,
|
||||
pcmPrivateData->uSampleRate,
|
||||
pcmPrivateData->uBitsPerSample,
|
||||
pcmPrivateData->bLittleEndian);
|
||||
}
|
||||
|
||||
unsigned char *buffer = call->data;
|
||||
unsigned int size = call->len;
|
||||
|
||||
unsigned int n;
|
||||
unsigned char *injectBuffer = (unsigned char *) malloc(SubFrameLen);
|
||||
unsigned int pos;
|
||||
|
||||
for (pos = 0; pos < size;) {
|
||||
//printf("PCM %s - Position=%d\n", __FUNCTION__, pos);
|
||||
if ((size - pos) < SubFrameLen) {
|
||||
breakBufferFillSize = size - pos;
|
||||
memcpy(breakBuffer, &buffer[pos],
|
||||
sizeof(unsigned char) * breakBufferFillSize);
|
||||
//printf("PCM %s - Unplayed=%d\n", __FUNCTION__, breakBufferFillSize);
|
||||
break;
|
||||
}
|
||||
//get first PES's worth
|
||||
if (breakBufferFillSize > 0) {
|
||||
memcpy(injectBuffer, breakBuffer,
|
||||
sizeof(unsigned char) * breakBufferFillSize);
|
||||
memcpy(&injectBuffer[breakBufferFillSize], &buffer[pos],
|
||||
sizeof(unsigned char) * (SubFrameLen -
|
||||
breakBufferFillSize));
|
||||
pos += (SubFrameLen - breakBufferFillSize);
|
||||
breakBufferFillSize = 0;
|
||||
} else {
|
||||
memcpy(injectBuffer, &buffer[pos],
|
||||
sizeof(unsigned char) * SubFrameLen);
|
||||
pos += SubFrameLen;
|
||||
}
|
||||
|
||||
pcm_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
struct iovec iov[3];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[1].iov_base = lpcm_prv;
|
||||
iov[1].iov_len = sizeof(lpcm_prv);
|
||||
|
||||
if (!call->data || (call->len <= 0)) {
|
||||
pcm_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
iov[2].iov_base = injectBuffer;
|
||||
iov[2].iov_len = SubFrameLen;
|
||||
|
||||
//write the PCM data
|
||||
if (pcmPrivateData->uBitsPerSample == 16) {
|
||||
for (n = 0; n < SubFrameLen; n += 2) {
|
||||
unsigned char tmp;
|
||||
tmp = injectBuffer[n];
|
||||
injectBuffer[n] = injectBuffer[n + 1];
|
||||
injectBuffer[n + 1] = tmp;
|
||||
}
|
||||
} else {
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
// A1c A1b A1a-B1c B1b B1a-A2c A2b A2a-B2c B2b B2a
|
||||
// to A1a A1b B1a B1b.A2a A2b B2a B2b-A1c B1c A2c B2c
|
||||
for (n = 0; n < SubFrameLen; n += 12) {
|
||||
unsigned char t, *p = &injectBuffer[n];
|
||||
t = p[0];
|
||||
p[0] = p[2];
|
||||
p[2] = p[5];
|
||||
p[5] = p[7];
|
||||
p[7] = p[11];
|
||||
p[11] = p[9];
|
||||
p[9] = p[3];
|
||||
p[3] = p[4];
|
||||
p[4] = p[8];
|
||||
p[8] = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (call->fd < 0) {
|
||||
pcm_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
//increment err... subframe count?
|
||||
lpcm_prv[1] = ((lpcm_prv[1] + SubFramesPerPES) & 0x1F);
|
||||
|
||||
pcmPrivateData_t* pcmPrivateData = (pcmPrivateData_t*)call->private_data;
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, iov[1].iov_len + iov[2].iov_len,
|
||||
PCM_PES_START_CODE, call->Pts, 0);
|
||||
int len = writev(call->fd, iov, 3);
|
||||
if (len < 0)
|
||||
break;
|
||||
}
|
||||
free(injectBuffer);
|
||||
|
||||
if (initialHeader) {
|
||||
initialHeader = 0;
|
||||
prepareClipPlay(pcmPrivateData->uNoOfChannels, pcmPrivateData->uSampleRate,
|
||||
pcmPrivateData->uBitsPerSample, pcmPrivateData->bLittleEndian);
|
||||
}
|
||||
|
||||
unsigned char * buffer = call->data;
|
||||
unsigned int size = call->len;
|
||||
|
||||
unsigned int n;
|
||||
unsigned char * injectBuffer = (unsigned char *)malloc(SubFrameLen);
|
||||
unsigned int pos;
|
||||
|
||||
for(pos = 0; pos < size; )
|
||||
{
|
||||
//printf("PCM %s - Position=%d\n", __FUNCTION__, pos);
|
||||
if((size - pos) < SubFrameLen)
|
||||
{
|
||||
breakBufferFillSize = size - pos;
|
||||
memcpy(breakBuffer, &buffer[pos], sizeof(unsigned char) * breakBufferFillSize);
|
||||
//printf("PCM %s - Unplayed=%d\n", __FUNCTION__, breakBufferFillSize);
|
||||
break;
|
||||
}
|
||||
|
||||
//get first PES's worth
|
||||
if(breakBufferFillSize > 0)
|
||||
{
|
||||
memcpy(injectBuffer, breakBuffer, sizeof(unsigned char)*breakBufferFillSize);
|
||||
memcpy(&injectBuffer[breakBufferFillSize], &buffer[pos], sizeof(unsigned char)*(SubFrameLen - breakBufferFillSize));
|
||||
pos += (SubFrameLen - breakBufferFillSize);
|
||||
breakBufferFillSize = 0;
|
||||
} else
|
||||
{
|
||||
memcpy(injectBuffer, &buffer[pos], sizeof(unsigned char)*SubFrameLen);
|
||||
pos += SubFrameLen;
|
||||
}
|
||||
|
||||
struct iovec iov[3];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[1].iov_base = lpcm_prv;
|
||||
iov[1].iov_len = sizeof(lpcm_prv);
|
||||
|
||||
iov[2].iov_base = injectBuffer;
|
||||
iov[2].iov_len = SubFrameLen;
|
||||
|
||||
//write the PCM data
|
||||
if(pcmPrivateData->uBitsPerSample == 16) {
|
||||
for(n=0; n<SubFrameLen; n+=2) {
|
||||
unsigned char tmp;
|
||||
tmp=injectBuffer[n];
|
||||
injectBuffer[n]=injectBuffer[n+1];
|
||||
injectBuffer[n+1]=tmp;
|
||||
}
|
||||
} else {
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
// A1c A1b A1a-B1c B1b B1a-A2c A2b A2a-B2c B2b B2a
|
||||
// to A1a A1b B1a B1b.A2a A2b B2a B2b-A1c B1c A2c B2c
|
||||
for(n=0; n<SubFrameLen; n+=12) {
|
||||
unsigned char t, *p = &injectBuffer[n];
|
||||
t = p[0];
|
||||
p[ 0] = p[ 2];
|
||||
p[ 2] = p[ 5];
|
||||
p[ 5] = p[ 7];
|
||||
p[ 7] = p[11];
|
||||
p[11] = p[ 9];
|
||||
p[ 9] = p[ 3];
|
||||
p[ 3] = p[ 4];
|
||||
p[ 4] = p[ 8];
|
||||
p[ 8] = t;
|
||||
}
|
||||
}
|
||||
|
||||
//increment err... subframe count?
|
||||
lpcm_prv[1] = ((lpcm_prv[1]+SubFramesPerPES) & 0x1F);
|
||||
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len + iov[2].iov_len, PCM_PES_START_CODE, call->Pts, 0);
|
||||
int len = writev(call->fd, iov, 3);
|
||||
if (len < 0)
|
||||
break;
|
||||
}
|
||||
free(injectBuffer);
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/* ***************************** */
|
||||
@@ -293,29 +308,29 @@ static int writeData(void* _call)
|
||||
/* ***************************** */
|
||||
|
||||
static WriterCaps_t caps_pcm = {
|
||||
"pcm",
|
||||
eAudio,
|
||||
"A_PCM",
|
||||
AUDIO_ENCODING_LPCMA
|
||||
"pcm",
|
||||
eAudio,
|
||||
"A_PCM",
|
||||
AUDIO_ENCODING_LPCMA
|
||||
};
|
||||
|
||||
struct Writer_s WriterAudioPCM = {
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps_pcm
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps_pcm
|
||||
};
|
||||
|
||||
static WriterCaps_t caps_ipcm = {
|
||||
"ipcm",
|
||||
eAudio,
|
||||
"A_IPCM",
|
||||
AUDIO_ENCODING_LPCMA
|
||||
"ipcm",
|
||||
eAudio,
|
||||
"A_IPCM",
|
||||
AUDIO_ENCODING_LPCMA
|
||||
};
|
||||
|
||||
struct Writer_s WriterAudioIPCM = {
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps_ipcm
|
||||
&reset,
|
||||
&writeData,
|
||||
NULL,
|
||||
&caps_ipcm
|
||||
};
|
||||
|
@@ -69,84 +69,83 @@
|
||||
|
||||
int InsertVideoPrivateDataHeader(unsigned char *data, int payload_size)
|
||||
{
|
||||
BitPacker_t ld2 = {data, 0, 32};
|
||||
int i;
|
||||
BitPacker_t ld2 = { data, 0, 32 };
|
||||
int i;
|
||||
|
||||
PutBits (&ld2, PES_PRIVATE_DATA_FLAG, 8);
|
||||
PutBits (&ld2, payload_size & 0xff, 8);
|
||||
PutBits (&ld2, (payload_size >> 8) & 0xff, 8);
|
||||
PutBits (&ld2, (payload_size >> 16) & 0xff, 8);
|
||||
PutBits(&ld2, PES_PRIVATE_DATA_FLAG, 8);
|
||||
PutBits(&ld2, payload_size & 0xff, 8);
|
||||
PutBits(&ld2, (payload_size >> 8) & 0xff, 8);
|
||||
PutBits(&ld2, (payload_size >> 16) & 0xff, 8);
|
||||
|
||||
for (i = 4; i < (PES_PRIVATE_DATA_LENGTH+1); i++)
|
||||
PutBits (&ld2, 0, 8);
|
||||
for (i = 4; i < (PES_PRIVATE_DATA_LENGTH + 1); i++)
|
||||
PutBits(&ld2, 0, 8);
|
||||
|
||||
FlushBits (&ld2);
|
||||
FlushBits(&ld2);
|
||||
|
||||
return PES_PRIVATE_DATA_LENGTH + 1;
|
||||
|
||||
}
|
||||
|
||||
int InsertPesHeader (unsigned char *data, int size, unsigned char stream_id, unsigned long long int pts, int pic_start_code)
|
||||
int InsertPesHeader(unsigned char *data, int size, unsigned char stream_id,
|
||||
unsigned long long int pts, int pic_start_code)
|
||||
{
|
||||
BitPacker_t ld2 = {data, 0, 32};
|
||||
BitPacker_t ld2 = { data, 0, 32 };
|
||||
|
||||
if (size > MAX_PES_PACKET_SIZE)
|
||||
size = 0; // unbounded
|
||||
size = 0; // unbounded
|
||||
|
||||
PutBits(&ld2,0x0 ,8);
|
||||
PutBits(&ld2,0x0 ,8);
|
||||
PutBits(&ld2,0x1 ,8); // Start Code
|
||||
PutBits(&ld2,stream_id ,8); // Stream_id = Audio Stream
|
||||
PutBits(&ld2, 0x0, 8);
|
||||
PutBits(&ld2, 0x0, 8);
|
||||
PutBits(&ld2, 0x1, 8); // Start Code
|
||||
PutBits(&ld2, stream_id, 8); // Stream_id = Audio Stream
|
||||
//4
|
||||
PutBits(&ld2,size + 3 + (pts != INVALID_PTS_VALUE ? 5:0) + (pic_start_code ? (5) : 0),16); // PES_packet_length
|
||||
PutBits(&ld2, size + 3 + (pts != INVALID_PTS_VALUE ? 5 : 0) + (pic_start_code ? (5) : 0), 16); // PES_packet_length
|
||||
//6 = 4+2
|
||||
PutBits(&ld2,0x2 ,2); // 10
|
||||
PutBits(&ld2,0x0 ,2); // PES_Scrambling_control
|
||||
PutBits(&ld2,0x0 ,1); // PES_Priority
|
||||
PutBits(&ld2,0x0 ,1); // data_alignment_indicator
|
||||
PutBits(&ld2,0x0 ,1); // Copyright
|
||||
PutBits(&ld2,0x0 ,1); // Original or Copy
|
||||
PutBits(&ld2, 0x2, 2); // 10
|
||||
PutBits(&ld2, 0x0, 2); // PES_Scrambling_control
|
||||
PutBits(&ld2, 0x0, 1); // PES_Priority
|
||||
PutBits(&ld2, 0x0, 1); // data_alignment_indicator
|
||||
PutBits(&ld2, 0x0, 1); // Copyright
|
||||
PutBits(&ld2, 0x0, 1); // Original or Copy
|
||||
//7 = 6+1
|
||||
|
||||
if (pts!=INVALID_PTS_VALUE)
|
||||
PutBits(&ld2,0x2 ,2);
|
||||
if (pts != INVALID_PTS_VALUE)
|
||||
PutBits(&ld2, 0x2, 2);
|
||||
else
|
||||
PutBits(&ld2,0x0 ,2); // PTS_DTS flag
|
||||
PutBits(&ld2, 0x0, 2); // PTS_DTS flag
|
||||
|
||||
PutBits(&ld2,0x0 ,1); // ESCR_flag
|
||||
PutBits(&ld2,0x0 ,1); // ES_rate_flag
|
||||
PutBits(&ld2,0x0 ,1); // DSM_trick_mode_flag
|
||||
PutBits(&ld2,0x0 ,1); // additional_copy_ingo_flag
|
||||
PutBits(&ld2,0x0 ,1); // PES_CRC_flag
|
||||
PutBits(&ld2,0x0 ,1); // PES_extension_flag
|
||||
PutBits(&ld2, 0x0, 1); // ESCR_flag
|
||||
PutBits(&ld2, 0x0, 1); // ES_rate_flag
|
||||
PutBits(&ld2, 0x0, 1); // DSM_trick_mode_flag
|
||||
PutBits(&ld2, 0x0, 1); // additional_copy_ingo_flag
|
||||
PutBits(&ld2, 0x0, 1); // PES_CRC_flag
|
||||
PutBits(&ld2, 0x0, 1); // PES_extension_flag
|
||||
//8 = 7+1
|
||||
|
||||
if (pts!=INVALID_PTS_VALUE)
|
||||
PutBits(&ld2,0x5,8);
|
||||
if (pts != INVALID_PTS_VALUE)
|
||||
PutBits(&ld2, 0x5, 8);
|
||||
else
|
||||
PutBits(&ld2,0x0 ,8); // PES_header_data_length
|
||||
PutBits(&ld2, 0x0, 8); // PES_header_data_length
|
||||
//9 = 8+1
|
||||
|
||||
if (pts!=INVALID_PTS_VALUE)
|
||||
{
|
||||
PutBits(&ld2,0x2,4);
|
||||
PutBits(&ld2,(pts>>30) & 0x7,3);
|
||||
PutBits(&ld2,0x1,1);
|
||||
PutBits(&ld2,(pts>>15) & 0x7fff,15);
|
||||
PutBits(&ld2,0x1,1);
|
||||
PutBits(&ld2,pts & 0x7fff,15);
|
||||
PutBits(&ld2,0x1,1);
|
||||
if (pts != INVALID_PTS_VALUE) {
|
||||
PutBits(&ld2, 0x2, 4);
|
||||
PutBits(&ld2, (pts >> 30) & 0x7, 3);
|
||||
PutBits(&ld2, 0x1, 1);
|
||||
PutBits(&ld2, (pts >> 15) & 0x7fff, 15);
|
||||
PutBits(&ld2, 0x1, 1);
|
||||
PutBits(&ld2, pts & 0x7fff, 15);
|
||||
PutBits(&ld2, 0x1, 1);
|
||||
}
|
||||
//14 = 9+5
|
||||
|
||||
if (pic_start_code)
|
||||
{
|
||||
PutBits(&ld2,0x0 ,8);
|
||||
PutBits(&ld2,0x0 ,8);
|
||||
PutBits(&ld2,0x1 ,8); // Start Code
|
||||
PutBits(&ld2,pic_start_code & 0xff ,8); // 00, for picture start
|
||||
PutBits(&ld2,(pic_start_code >> 8 )&0xff,8); // For any extra information (like in mpeg4p2, the pic_start_code)
|
||||
//14 + 4 = 18
|
||||
if (pic_start_code) {
|
||||
PutBits(&ld2, 0x0, 8);
|
||||
PutBits(&ld2, 0x0, 8);
|
||||
PutBits(&ld2, 0x1, 8); // Start Code
|
||||
PutBits(&ld2, pic_start_code & 0xff, 8); // 00, for picture start
|
||||
PutBits(&ld2, (pic_start_code >> 8) & 0xff, 8); // For any extra information (like in mpeg4p2, the pic_start_code)
|
||||
//14 + 4 = 18
|
||||
}
|
||||
|
||||
FlushBits(&ld2);
|
||||
|
@@ -85,20 +85,20 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
static const unsigned char SequenceLayerStartCode[] = {0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE};
|
||||
static const unsigned char SequenceLayerStartCode[] =
|
||||
{ 0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE };
|
||||
|
||||
|
||||
static const unsigned char Metadata[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0xc5,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile*/
|
||||
0x00, 0x00, 0x00, 0x00, /* Struct A */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, /* Struct B */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
static const unsigned char Metadata[] = {
|
||||
0x00, 0x00, 0x00, 0xc5,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile */
|
||||
0x00, 0x00, 0x00, 0x00, /* Struct A */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, /* Struct B */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* ***************************** */
|
||||
@@ -121,9 +121,9 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
int len = 0;
|
||||
|
||||
@@ -151,81 +151,94 @@ static int writeData(void* _call)
|
||||
|
||||
if (initialHeader) {
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesPayload[128];
|
||||
unsigned char* PesPtr;
|
||||
unsigned int crazyFramerate = 0;
|
||||
struct iovec iov[2];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesPayload[128];
|
||||
unsigned char *PesPtr;
|
||||
unsigned int crazyFramerate = 0;
|
||||
struct iovec iov[2];
|
||||
|
||||
vc1_printf(10, "Framerate: %u\n", call->FrameRate);
|
||||
vc1_printf(10, "biWidth: %d\n", call->Width);
|
||||
vc1_printf(10, "biHeight: %d\n", call->Height);
|
||||
vc1_printf(10, "biWidth: %d\n", call->Width);
|
||||
vc1_printf(10, "biHeight: %d\n", call->Height);
|
||||
|
||||
crazyFramerate = ((10000000.0 / call->FrameRate) * 1000.0);
|
||||
vc1_printf(10, "crazyFramerate: %u\n", crazyFramerate);
|
||||
|
||||
memset(PesPayload, 0, sizeof(PesPayload));
|
||||
|
||||
PesPtr = PesPayload;
|
||||
PesPtr = PesPayload;
|
||||
|
||||
memcpy (PesPtr, SequenceLayerStartCode, sizeof(SequenceLayerStartCode));
|
||||
PesPtr += sizeof(SequenceLayerStartCode);
|
||||
memcpy(PesPtr, SequenceLayerStartCode,
|
||||
sizeof(SequenceLayerStartCode));
|
||||
PesPtr += sizeof(SequenceLayerStartCode);
|
||||
|
||||
memcpy (PesPtr, Metadata, sizeof(Metadata));
|
||||
memcpy(PesPtr, Metadata, sizeof(Metadata));
|
||||
PesPtr += METADATA_STRUCT_C_START;
|
||||
PesPtr += WMV3_PRIVATE_DATA_LENGTH;
|
||||
|
||||
/* Metadata Header Struct A */
|
||||
*PesPtr++ = (call->Height >> 0) & 0xff;
|
||||
*PesPtr++ = (call->Height >> 8) & 0xff;
|
||||
*PesPtr++ = (call->Height >> 0) & 0xff;
|
||||
*PesPtr++ = (call->Height >> 8) & 0xff;
|
||||
*PesPtr++ = (call->Height >> 16) & 0xff;
|
||||
*PesPtr++ = call->Height >> 24;
|
||||
*PesPtr++ = (call->Width >> 0) & 0xff;
|
||||
*PesPtr++ = (call->Width >> 8) & 0xff;
|
||||
*PesPtr++ = (call->Width >> 16) & 0xff;
|
||||
*PesPtr++ = call->Width >> 24;
|
||||
*PesPtr++ = call->Height >> 24;
|
||||
*PesPtr++ = (call->Width >> 0) & 0xff;
|
||||
*PesPtr++ = (call->Width >> 8) & 0xff;
|
||||
*PesPtr++ = (call->Width >> 16) & 0xff;
|
||||
*PesPtr++ = call->Width >> 24;
|
||||
|
||||
PesPtr += 12; /* Skip flag word and Struct B first 8 bytes */
|
||||
PesPtr += 12; /* Skip flag word and Struct B first 8 bytes */
|
||||
|
||||
*PesPtr++ = (crazyFramerate >> 0) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 8) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 0) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 8) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 16) & 0xff;
|
||||
*PesPtr++ = crazyFramerate >> 24;
|
||||
*PesPtr++ = crazyFramerate >> 24;
|
||||
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[1].iov_base = PesPayload;
|
||||
iov[1].iov_len = PesPtr - PesPayload;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, iov[1].iov_len,
|
||||
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
|
||||
0);
|
||||
len = writev(call->fd, iov, 2);
|
||||
|
||||
/* For VC1 the codec private data is a standard vc1 sequence header so we just copy it to the output */
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[1].iov_base = call->private_data;
|
||||
iov[1].iov_len = call->private_size;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, iov[1].iov_len,
|
||||
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
|
||||
0);
|
||||
len = writev(call->fd, iov, 2);
|
||||
|
||||
initialHeader = 0;
|
||||
}
|
||||
|
||||
if(call->len > 0 && call->data) {
|
||||
if (call->len > 0 && call->data) {
|
||||
unsigned int Position = 0;
|
||||
unsigned char insertSampleHeader = 1;
|
||||
|
||||
while(Position < call->len) {
|
||||
while (Position < call->len) {
|
||||
|
||||
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
int PacketLength =
|
||||
(call->len - Position) <=
|
||||
MAX_PES_PACKET_SIZE ? (call->len -
|
||||
Position) : MAX_PES_PACKET_SIZE;
|
||||
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
|
||||
vc1_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
vc1_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
|
||||
PacketLength, Remaining, Position);
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
int HeaderLength = InsertPesHeader (PesHeader, PacketLength, VC1_VIDEO_PES_START_CODE, call->Pts, 0);
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
int HeaderLength =
|
||||
InsertPesHeader(PesHeader, PacketLength,
|
||||
VC1_VIDEO_PES_START_CODE, call->Pts, 0);
|
||||
|
||||
if(insertSampleHeader) {
|
||||
const unsigned char Vc1FrameStartCode[] = {0, 0, 1, VC1_FRAME_START_CODE};
|
||||
if (insertSampleHeader) {
|
||||
const unsigned char Vc1FrameStartCode[] =
|
||||
{ 0, 0, 1, VC1_FRAME_START_CODE };
|
||||
|
||||
/*
|
||||
vc1_printf(10, "Data Start: {00 00 01 0d} - ");
|
||||
@@ -234,13 +247,14 @@ static int writeData(void* _call)
|
||||
vc1_printf(10, "\n");
|
||||
*/
|
||||
|
||||
if (!FrameHeaderSeen && (call->len > 3) && (memcmp (call->data, Vc1FrameStartCode, 4) == 0))
|
||||
FrameHeaderSeen = 1;
|
||||
if (!FrameHeaderSeen)
|
||||
{
|
||||
memcpy (&PesHeader[HeaderLength], Vc1FrameStartCode, sizeof(Vc1FrameStartCode));
|
||||
HeaderLength += sizeof(Vc1FrameStartCode);
|
||||
}
|
||||
if (!FrameHeaderSeen && (call->len > 3)
|
||||
&& (memcmp(call->data, Vc1FrameStartCode, 4) == 0))
|
||||
FrameHeaderSeen = 1;
|
||||
if (!FrameHeaderSeen) {
|
||||
memcpy(&PesHeader[HeaderLength], Vc1FrameStartCode,
|
||||
sizeof(Vc1FrameStartCode));
|
||||
HeaderLength += sizeof(Vc1FrameStartCode);
|
||||
}
|
||||
insertSampleHeader = 0;
|
||||
}
|
||||
|
||||
|
@@ -93,72 +93,71 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
int len = 0;
|
||||
|
||||
wma_printf(10, "\n");
|
||||
|
||||
if (call == NULL)
|
||||
{
|
||||
wma_err("call data is NULL...\n");
|
||||
return 0;
|
||||
if (call == NULL) {
|
||||
wma_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
wma_printf(10, "AudioPts %lld\n", call->Pts);
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0))
|
||||
{
|
||||
wma_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
wma_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0)
|
||||
{
|
||||
wma_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
if (call->fd < 0) {
|
||||
wma_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (initialHeader) {
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
if ((call->private_size <= 0) || (call->private_data == NULL))
|
||||
{
|
||||
wma_err("private NULL.\n");
|
||||
return -1;
|
||||
}
|
||||
if ((call->private_size <= 0) || (call->private_data == NULL)) {
|
||||
wma_err("private NULL.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->private_size, MPEG_AUDIO_PES_START_CODE, 0, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->private_size,
|
||||
MPEG_AUDIO_PES_START_CODE, 0, 0);
|
||||
iov[1].iov_base = call->private_data;
|
||||
iov[1].iov_len = call->private_size;
|
||||
|
||||
len = writev(call->fd, iov, 2);
|
||||
len = writev(call->fd, iov, 2);
|
||||
|
||||
initialHeader = 0;
|
||||
initialHeader = 0;
|
||||
}
|
||||
|
||||
if (len > -1 && call->len > 0 && call->data)
|
||||
{
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
if (len > -1 && call->len > 0 && call->data) {
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
||||
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
iov[0].iov_len =
|
||||
InsertPesHeader(PesHeader, call->len,
|
||||
MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
iov[1].iov_base = call->data;
|
||||
iov[1].iov_len = call->len;
|
||||
|
||||
ssize_t l = writev(call->fd, iov, 2);
|
||||
ssize_t l = writev(call->fd, iov, 2);
|
||||
if (l > -1)
|
||||
len += l;
|
||||
len += l;
|
||||
else
|
||||
len = l;
|
||||
len = l;
|
||||
}
|
||||
|
||||
wma_printf(10, "wma < %d\n", len);
|
||||
|
@@ -81,25 +81,23 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char privateData[WMV3_PRIVATE_DATA_LENGTH];
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int framerate;
|
||||
typedef struct {
|
||||
unsigned char privateData[WMV3_PRIVATE_DATA_LENGTH];
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int framerate;
|
||||
} awmv_t;
|
||||
|
||||
static const unsigned char Metadata[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0xc5,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile*/
|
||||
0x00, 0x00, 0x00, 0x00, /* Struct A */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, /* Struct B */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
static const unsigned char Metadata[] = {
|
||||
0x00, 0x00, 0x00, 0xc5,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile */
|
||||
0x00, 0x00, 0x00, 0x00, /* Struct A */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, /* Struct B */
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* ***************************** */
|
||||
@@ -120,9 +118,9 @@ static int reset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeData(void* _call)
|
||||
static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
|
||||
awmv_t private_data;
|
||||
int len = 0;
|
||||
@@ -130,25 +128,27 @@ static int writeData(void* _call)
|
||||
wmv_printf(10, "\n");
|
||||
|
||||
if (call == NULL) {
|
||||
wmv_err("call data is NULL...\n");
|
||||
return 0;
|
||||
wmv_err("call data is NULL...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((call->data == NULL) || (call->len <= 0)) {
|
||||
wmv_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
wmv_err("parsing NULL Data. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (call->fd < 0) {
|
||||
wmv_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
wmv_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
wmv_printf(10, "VideoPts %lld\n", call->Pts);
|
||||
wmv_printf(10, "Got Private Size %d\n", call->private_size);
|
||||
|
||||
memcpy(private_data.privateData, call->private_data,
|
||||
call->private_size>WMV3_PRIVATE_DATA_LENGTH?WMV3_PRIVATE_DATA_LENGTH:call->private_size);
|
||||
call->private_size >
|
||||
WMV3_PRIVATE_DATA_LENGTH ? WMV3_PRIVATE_DATA_LENGTH : call->
|
||||
private_size);
|
||||
|
||||
private_data.width = call->Width;
|
||||
private_data.height = call->Height;
|
||||
@@ -156,97 +156,110 @@ static int writeData(void* _call)
|
||||
|
||||
#define PES_MIN_HEADER_SIZE 9
|
||||
if (initialHeader) {
|
||||
unsigned char PesPacket[PES_MIN_HEADER_SIZE+128];
|
||||
unsigned char* PesPtr;
|
||||
unsigned int MetadataLength;
|
||||
unsigned int crazyFramerate = 0;
|
||||
unsigned char PesPacket[PES_MIN_HEADER_SIZE + 128];
|
||||
unsigned char *PesPtr;
|
||||
unsigned int MetadataLength;
|
||||
unsigned int crazyFramerate = 0;
|
||||
|
||||
wmv_printf(10, "Framerate: %u\n", private_data.framerate);
|
||||
wmv_printf(10, "biWidth: %d\n", private_data.width);
|
||||
wmv_printf(10, "biHeight: %d\n", private_data.height);
|
||||
wmv_printf(10, "Framerate: %u\n", private_data.framerate);
|
||||
wmv_printf(10, "biWidth: %d\n", private_data.width);
|
||||
wmv_printf(10, "biHeight: %d\n", private_data.height);
|
||||
|
||||
crazyFramerate = ((10000000.0 / private_data.framerate) * 1000.0);
|
||||
wmv_printf(10, "crazyFramerate: %u\n", crazyFramerate);
|
||||
crazyFramerate = ((10000000.0 / private_data.framerate) * 1000.0);
|
||||
wmv_printf(10, "crazyFramerate: %u\n", crazyFramerate);
|
||||
|
||||
PesPtr = &PesPacket[PES_MIN_HEADER_SIZE];
|
||||
PesPtr = &PesPacket[PES_MIN_HEADER_SIZE];
|
||||
|
||||
memcpy (PesPtr, Metadata, sizeof(Metadata));
|
||||
PesPtr += METADATA_STRUCT_C_START;
|
||||
memcpy(PesPtr, Metadata, sizeof(Metadata));
|
||||
PesPtr += METADATA_STRUCT_C_START;
|
||||
|
||||
memcpy (PesPtr, private_data.privateData, WMV3_PRIVATE_DATA_LENGTH);
|
||||
PesPtr += WMV3_PRIVATE_DATA_LENGTH;
|
||||
memcpy(PesPtr, private_data.privateData, WMV3_PRIVATE_DATA_LENGTH);
|
||||
PesPtr += WMV3_PRIVATE_DATA_LENGTH;
|
||||
|
||||
/* Metadata Header Struct A */
|
||||
*PesPtr++ = (private_data.height >> 0) & 0xff;
|
||||
*PesPtr++ = (private_data.height >> 8) & 0xff;
|
||||
*PesPtr++ = (private_data.height >> 16) & 0xff;
|
||||
*PesPtr++ = private_data.height >> 24;
|
||||
*PesPtr++ = (private_data.width >> 0) & 0xff;
|
||||
*PesPtr++ = (private_data.width >> 8) & 0xff;
|
||||
*PesPtr++ = (private_data.width >> 16) & 0xff;
|
||||
*PesPtr++ = private_data.width >> 24;
|
||||
/* Metadata Header Struct A */
|
||||
*PesPtr++ = (private_data.height >> 0) & 0xff;
|
||||
*PesPtr++ = (private_data.height >> 8) & 0xff;
|
||||
*PesPtr++ = (private_data.height >> 16) & 0xff;
|
||||
*PesPtr++ = private_data.height >> 24;
|
||||
*PesPtr++ = (private_data.width >> 0) & 0xff;
|
||||
*PesPtr++ = (private_data.width >> 8) & 0xff;
|
||||
*PesPtr++ = (private_data.width >> 16) & 0xff;
|
||||
*PesPtr++ = private_data.width >> 24;
|
||||
|
||||
PesPtr += 12; /* Skip flag word and Struct B first 8 bytes */
|
||||
PesPtr += 12; /* Skip flag word and Struct B first 8 bytes */
|
||||
|
||||
*PesPtr++ = (crazyFramerate >> 0) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 8) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 16) & 0xff;
|
||||
*PesPtr++ = crazyFramerate >> 24;
|
||||
*PesPtr++ = (crazyFramerate >> 0) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 8) & 0xff;
|
||||
*PesPtr++ = (crazyFramerate >> 16) & 0xff;
|
||||
*PesPtr++ = crazyFramerate >> 24;
|
||||
|
||||
MetadataLength = PesPtr - &PesPacket[PES_MIN_HEADER_SIZE];
|
||||
MetadataLength = PesPtr - &PesPacket[PES_MIN_HEADER_SIZE];
|
||||
|
||||
int HeaderLength = InsertPesHeader (PesPacket, MetadataLength, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
int HeaderLength =
|
||||
InsertPesHeader(PesPacket, MetadataLength,
|
||||
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
|
||||
0);
|
||||
|
||||
len = write(call->fd,PesPacket, HeaderLength + MetadataLength);
|
||||
len = write(call->fd, PesPacket, HeaderLength + MetadataLength);
|
||||
|
||||
initialHeader = 0;
|
||||
initialHeader = 0;
|
||||
}
|
||||
|
||||
if(call->len > 0 && call->data) {
|
||||
unsigned int Position = 0;
|
||||
unsigned char insertSampleHeader = 1;
|
||||
while(Position < call->len) {
|
||||
if (call->len > 0 && call->data) {
|
||||
unsigned int Position = 0;
|
||||
unsigned char insertSampleHeader = 1;
|
||||
while (Position < call->len) {
|
||||
|
||||
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
int PacketLength =
|
||||
(call->len - Position) <=
|
||||
MAX_PES_PACKET_SIZE ? (call->len -
|
||||
Position) : MAX_PES_PACKET_SIZE;
|
||||
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
|
||||
wmv_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
wmv_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
|
||||
PacketLength, Remaining, Position);
|
||||
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
memset (PesHeader, '0', PES_MAX_HEADER_SIZE);
|
||||
int HeaderLength = InsertPesHeader (PesHeader, PacketLength, VC1_VIDEO_PES_START_CODE, call->Pts, 0);
|
||||
unsigned char* PacketStart;
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
memset(PesHeader, '0', PES_MAX_HEADER_SIZE);
|
||||
int HeaderLength =
|
||||
InsertPesHeader(PesHeader, PacketLength,
|
||||
VC1_VIDEO_PES_START_CODE, call->Pts, 0);
|
||||
unsigned char *PacketStart;
|
||||
|
||||
if(insertSampleHeader) {
|
||||
unsigned int PesLength;
|
||||
unsigned int PrivateHeaderLength;
|
||||
if (insertSampleHeader) {
|
||||
unsigned int PesLength;
|
||||
unsigned int PrivateHeaderLength;
|
||||
|
||||
PrivateHeaderLength = InsertVideoPrivateDataHeader (&PesHeader[HeaderLength],
|
||||
call->len);
|
||||
/* Update PesLength */
|
||||
PesLength = PesHeader[PES_LENGTH_BYTE_0] +
|
||||
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
|
||||
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
|
||||
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] += PrivateHeaderLength;
|
||||
PesHeader[PES_FLAGS_BYTE] |= PES_EXTENSION_DATA_PRESENT;
|
||||
PrivateHeaderLength =
|
||||
InsertVideoPrivateDataHeader(&PesHeader[HeaderLength],
|
||||
call->len);
|
||||
/* Update PesLength */
|
||||
PesLength = PesHeader[PES_LENGTH_BYTE_0] +
|
||||
(PesHeader[PES_LENGTH_BYTE_1] << 8) +
|
||||
PrivateHeaderLength;
|
||||
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
|
||||
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] +=
|
||||
PrivateHeaderLength;
|
||||
PesHeader[PES_FLAGS_BYTE] |= PES_EXTENSION_DATA_PRESENT;
|
||||
|
||||
HeaderLength += PrivateHeaderLength;
|
||||
insertSampleHeader = 0;
|
||||
}
|
||||
HeaderLength += PrivateHeaderLength;
|
||||
insertSampleHeader = 0;
|
||||
}
|
||||
|
||||
PacketStart = malloc(call->len + HeaderLength);
|
||||
memcpy (PacketStart, PesHeader, HeaderLength);
|
||||
memcpy (PacketStart + HeaderLength, call->data + Position, PacketLength);
|
||||
PacketStart = malloc(call->len + HeaderLength);
|
||||
memcpy(PacketStart, PesHeader, HeaderLength);
|
||||
memcpy(PacketStart + HeaderLength, call->data + Position,
|
||||
PacketLength);
|
||||
|
||||
len = write(call->fd, PacketStart, PacketLength + HeaderLength);
|
||||
free(PacketStart);
|
||||
len =
|
||||
write(call->fd, PacketStart, PacketLength + HeaderLength);
|
||||
free(PacketStart);
|
||||
|
||||
Position += PacketLength;
|
||||
call->Pts = INVALID_PTS_VALUE;
|
||||
}
|
||||
Position += PacketLength;
|
||||
call->Pts = INVALID_PTS_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
wmv_printf(10, "< %d\n", len);
|
||||
|
@@ -58,7 +58,7 @@ if (debug_level >= level) printf(x); } while (0)
|
||||
/* Varaibles */
|
||||
/* ***************************** */
|
||||
|
||||
static Writer_t * AvailableWriter[] = {
|
||||
static Writer_t *AvailableWriter[] = {
|
||||
&WriterAudioIPCM,
|
||||
&WriterAudioPCM,
|
||||
&WriterAudioMP3,
|
||||
@@ -93,35 +93,35 @@ static Writer_t * AvailableWriter[] = {
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
Writer_t* getWriter(char* encoding)
|
||||
Writer_t *getWriter(char *encoding)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++)
|
||||
{
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, encoding) == 0)
|
||||
{
|
||||
writer_printf(50, "%s: found writer \"%s\" for \"%s\"\n", __func__, AvailableWriter[i]->caps->name, encoding);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++) {
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, encoding) == 0) {
|
||||
writer_printf(50, "%s: found writer \"%s\" for \"%s\"\n",
|
||||
__func__, AvailableWriter[i]->caps->name,
|
||||
encoding);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
}
|
||||
|
||||
writer_printf(1, "%s: no writer found for \"%s\"\n", __func__, encoding);
|
||||
writer_printf(1, "%s: no writer found for \"%s\"\n", __func__,
|
||||
encoding);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Writer_t* getDefaultVideoWriter()
|
||||
Writer_t *getDefaultVideoWriter()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++)
|
||||
{
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "V_MPEG2") == 0)
|
||||
{
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++) {
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "V_MPEG2") == 0) {
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
|
||||
AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
}
|
||||
|
||||
writer_printf(1, "%s: no writer found\n", __func__);
|
||||
@@ -129,17 +129,16 @@ Writer_t* getDefaultVideoWriter()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Writer_t* getDefaultAudioWriter()
|
||||
Writer_t *getDefaultAudioWriter()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++)
|
||||
{
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "A_MP3") == 0)
|
||||
{
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++) {
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "A_MP3") == 0) {
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
|
||||
AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
}
|
||||
|
||||
writer_printf(1, "%s: no writer found\n", __func__);
|
||||
@@ -147,18 +146,18 @@ Writer_t* getDefaultAudioWriter()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Writer_t* getDefaultFramebufferWriter()
|
||||
Writer_t *getDefaultFramebufferWriter()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++)
|
||||
{
|
||||
writer_printf(10, "%s\n", AvailableWriter[i]->caps->textEncoding);
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "framebuffer") == 0)
|
||||
{
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
for (i = 0; AvailableWriter[i] != NULL; i++) {
|
||||
writer_printf(10, "%s\n", AvailableWriter[i]->caps->textEncoding);
|
||||
if (strcmp(AvailableWriter[i]->caps->textEncoding, "framebuffer")
|
||||
== 0) {
|
||||
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
|
||||
AvailableWriter[i]->caps->name);
|
||||
return AvailableWriter[i];
|
||||
}
|
||||
}
|
||||
|
||||
writer_printf(1, "%s: no writer found\n", __func__);
|
||||
|
Reference in New Issue
Block a user