|
|
|
@ -95,7 +95,8 @@ xrdpvr_deinit_player(void *channel, int stream_id)
|
|
|
|
|
av_free(g_psi.frame);
|
|
|
|
|
avcodec_close(g_psi.p_audio_codec_ctx);
|
|
|
|
|
avcodec_close(g_psi.p_video_codec_ctx);
|
|
|
|
|
avformat_close_input(&g_psi.p_format_ctx);
|
|
|
|
|
//avformat_close_input(&g_psi.p_format_ctx);
|
|
|
|
|
av_close_input_file(g_psi.p_format_ctx);
|
|
|
|
|
|
|
|
|
|
/* do remote cleanup */
|
|
|
|
|
|
|
|
|
@ -141,14 +142,16 @@ xrdpvr_play_media(void *channel, int stream_id, char *filename)
|
|
|
|
|
av_register_all();
|
|
|
|
|
|
|
|
|
|
/* open media file - this will read just the header */
|
|
|
|
|
if (avformat_open_input(&g_psi.p_format_ctx, filename, NULL, NULL))
|
|
|
|
|
//if (avformat_open_input(&g_psi.p_format_ctx, filename, NULL, NULL))
|
|
|
|
|
if (av_open_input_file(&g_psi.p_format_ctx, filename, NULL, 0, NULL))
|
|
|
|
|
{
|
|
|
|
|
printf("ERROR opening %s\n", filename);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now get the real stream info */
|
|
|
|
|
if (avformat_find_stream_info(g_psi.p_format_ctx, NULL) < 0)
|
|
|
|
|
//if (avformat_find_stream_info(g_psi.p_format_ctx, NULL) < 0)
|
|
|
|
|
if (av_find_stream_info(g_psi.p_format_ctx) < 0)
|
|
|
|
|
{
|
|
|
|
|
printf("ERRRO reading stream info\n");
|
|
|
|
|
return -1;
|
|
|
|
@ -162,13 +165,13 @@ xrdpvr_play_media(void *channel, int stream_id, char *filename)
|
|
|
|
|
/* find first audio / video stream */
|
|
|
|
|
for (i = 0; i < g_psi.p_format_ctx->nb_streams; i++)
|
|
|
|
|
{
|
|
|
|
|
if (g_psi.p_format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
|
|
|
|
|
if (g_psi.p_format_ctx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO &&
|
|
|
|
|
g_video_index < 0)
|
|
|
|
|
{
|
|
|
|
|
g_video_index = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g_psi.p_format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
|
|
|
|
|
if (g_psi.p_format_ctx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO &&
|
|
|
|
|
g_audio_index < 0)
|
|
|
|
|
{
|
|
|
|
|
g_audio_index = i;
|
|
|
|
@ -179,7 +182,8 @@ xrdpvr_play_media(void *channel, int stream_id, char *filename)
|
|
|
|
|
{
|
|
|
|
|
/* close file and return with error */
|
|
|
|
|
printf("ERROR: no audio/video stream found in %s\n", filename);
|
|
|
|
|
avformat_close_input(&g_psi.p_format_ctx);
|
|
|
|
|
//avformat_close_input(&g_psi.p_format_ctx);
|
|
|
|
|
av_close_input_file(g_psi.p_format_ctx);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -207,16 +211,18 @@ xrdpvr_play_media(void *channel, int stream_id, char *filename)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* open decoder for audio stream */
|
|
|
|
|
if (avcodec_open2(g_psi.p_audio_codec_ctx, g_psi.p_audio_codec,
|
|
|
|
|
NULL) < 0)
|
|
|
|
|
//if (avcodec_open2(g_psi.p_audio_codec_ctx, g_psi.p_audio_codec,
|
|
|
|
|
// NULL) < 0)
|
|
|
|
|
if (avcodec_open(g_psi.p_audio_codec_ctx, g_psi.p_audio_codec) < 0)
|
|
|
|
|
{
|
|
|
|
|
printf("ERROR: could not open audio decoder\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* open decoder for video stream */
|
|
|
|
|
if (avcodec_open2(g_psi.p_video_codec_ctx, g_psi.p_video_codec,
|
|
|
|
|
NULL) < 0)
|
|
|
|
|
//if (avcodec_open2(g_psi.p_video_codec_ctx, g_psi.p_video_codec,
|
|
|
|
|
// NULL) < 0)
|
|
|
|
|
if (avcodec_open(g_psi.p_video_codec_ctx, g_psi.p_video_codec) < 0)
|
|
|
|
|
{
|
|
|
|
|
printf("ERROR: could not open video decoder\n");
|
|
|
|
|
return -1;
|
|
|
|
@ -342,7 +348,7 @@ int xrdpvr_play_frame(void *channel, int stream_id, int *videoTimeout, int *audi
|
|
|
|
|
*audioTimeout = (int) ((dts - g_psi.audioTimeout) * 1000000);
|
|
|
|
|
*videoTimeout = -1;
|
|
|
|
|
|
|
|
|
|
if (g_psi.audioTimeout > dts)
|
|
|
|
|
if (g_psi.audioTimeout > dts)
|
|
|
|
|
{
|
|
|
|
|
g_psi.audioTimeout = dts;
|
|
|
|
|
delay_in_us = 1000 * 40;
|
|
|
|
@ -728,4 +734,3 @@ xrdpvr_write_to_client(void *channel, STREAM *s)
|
|
|
|
|
usleep(1000 * 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|