Beispiel #1
0
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);

    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");
            }
        } 
        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");
            }
        } 
        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");
            }
            // success or not executed, dunn care
            if (!ret) 
            {
                if (context->playback->isAudio)
                {
                    ret = context->output->audio->Command(context, OUTPUT_PLAY, "audio");
                }
            }
            if (!ret) 
            {
                if (context->playback->isSubtitle)
                {
                    ret = context->output->subtitle->Command(context, OUTPUT_PLAY, "subtitle");
                }
            }
        } 
        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");
            }
        } 
        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");
            }
        } 
        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");
            }
        } 
        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");
            }
        } 
        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);
            }
        } 
        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->isSubtitle)
            {
                return context->output->subtitle->Command(context, OUTPUT_SWITCH, "subtitle");
            }
        } 
        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");
            }
        } 
        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);
            }
        }
        else
        {
            ret = cERR_OUTPUT_INTERNAL_ERROR;
        }
        break;
    case OUTPUT_GET_PROGRESSIVE:
    {
        if (context && context->playback)
        {
            if (context->playback->isVideo)
            {
                return context->output->video->Command(context, OUTPUT_GET_PROGRESSIVE, (void*) argument);
            }
        }
        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_printf(10, "%s::%s exiting with value %d\n", FILENAME, __FUNCTION__, ret);

    return ret;
}
Beispiel #2
0
static int Command(void  *_context, OutputCmd_t command, void * argument) {
Context_t  *context = (Context_t*) _context;
#ifdef DEBUG
	printf("%s::%s Command %d\n", FILENAME, __FUNCTION__, command);
#endif
	
	int ret = 0;
	
	switch(command) {
		case OUTPUT_OPEN: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_OPEN, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_OPEN, "audio");
				if (context->playback->isSubtitle)
					context->output->subtitle->Command(context, OUTPUT_OPEN, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_CLOSE: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_CLOSE, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_CLOSE, "audio");
				if (context->playback->isSubtitle)
					context->output->subtitle->Command(context, OUTPUT_CLOSE, "subtitle");
			} else
				ret = -1;
			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");
					}
				}
			} else
				ret = -1;
			break;
		}
		case OUTPUT_STOP: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_STOP, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_STOP, "audio");
				if (context->playback->isSubtitle)
					context->output->subtitle->Command(context, OUTPUT_STOP, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_FLUSH: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_FLUSH, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_FLUSH, "audio");
				//if (context->playback->isSubtitle)
				//	context->output->subtitle->Command(context, OUTPUT_FLUSH, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_PAUSE: {	// 6
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_PAUSE, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_PAUSE, "audio");
				//if (context->playback->isSubtitle)
				//	context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_FASTFORWARD: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_FASTFORWARD, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_FASTFORWARD, "audio");
				//if (context->playback->isSubtitle)
				//	context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_CONTINUE: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_CONTINUE, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_CONTINUE, "audio");
				//if (context->playback->isSubtitle)
				//	context->output->subtitle->Command(context, OUTPUT_CONTINUE, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_AVSYNC: {
			if (context && context->playback ) {
				if (context->playback->isVideo && context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_AVSYNC, "audio");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_CLEAR: {
			if (context && context->playback ) {
				if (context->playback->isVideo && (argument == NULL || *(char *) argument == 'v'))
					context->output->video->Command(context, OUTPUT_CLEAR, "video");
				if (context->playback->isAudio && (argument == NULL || *(char *) argument == 'a'))
					context->output->audio->Command(context, OUTPUT_CLEAR, "audio");
				//if (context->playback->isSubtitle && (argument == NULL || *(char *) argument == 's'))
				//	context->output->subtitle->Command(context, OUTPUT_CLEAR, "subtitle");
			} else
				ret = -1;
			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 = -1;
			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");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_SLOWMOTION: {
			if (context && context->playback ) {
				if (context->playback->isVideo)
					context->output->video->Command(context, OUTPUT_SLOWMOTION, "video");
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_SLOWMOTION, "audio");
				//if (context->playback->isSubtitle)
				//	context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
			} else
				ret = -1;
			break;
		}
		case OUTPUT_AUDIOMUTE: {
			if (context && context->playback ) {
				if (context->playback->isAudio)
					context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (char*) argument);
			} else
				ret = -1;
			break;
		}
		default:
#ifdef DEBUG
			printf("%s::%s OutputCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
#endif
			break;
	}

#ifdef DEBUG
	printf("%s::%s exiting with value %d\n", FILENAME, __FUNCTION__, ret);
#endif

	return ret;
}