From 8ca74d91654c5e1de25083db2fd58444d8428015 Mon Sep 17 00:00:00 2001 From: xufulong Date: Fri, 3 Dec 2021 20:35:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=9F=B3=E8=BD=A8=E5=B4=A9=E6=BA=83=E4=B8=8E=E9=9F=B3=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E4=B8=8D=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ijkmedia/ijkplayer/ff_ffplay.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/ijkmedia/ijkplayer/ff_ffplay.c b/ijkmedia/ijkplayer/ff_ffplay.c index 714a8c9d61..2cd8bc29bd 100755 --- a/ijkmedia/ijkplayer/ff_ffplay.c +++ b/ijkmedia/ijkplayer/ff_ffplay.c @@ -4837,38 +4837,50 @@ int ffp_set_stream_selected(FFPlayer *ffp, int stream, int selected) VideoState *is = ffp->is; AVFormatContext *ic = NULL; AVCodecParameters *codecpar = NULL; - if (!is) - return -1; - ic = is->ic; - if (!ic) + int change_stream = 0; + if (!is || !is->ic) return -1; + ic = is->ic; if (stream < 0 || stream >= ic->nb_streams) { av_log(ffp, AV_LOG_ERROR, "invalid stream index %d >= stream number (%d)\n", stream, ic->nb_streams); return -1; } codecpar = ic->streams[stream]->codecpar; + long current_pos = ffp_get_current_position_l(ffp); if (selected) { switch (codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: - if (stream != is->video_stream && is->video_stream >= 0) + if (stream != is->video_stream && is->video_stream >= 0) { stream_component_close(ffp, is->video_stream); + change_stream = 1; + } break; case AVMEDIA_TYPE_AUDIO: - if (stream != is->audio_stream && is->audio_stream >= 0) + if (stream != is->audio_stream && is->audio_stream >= 0) { stream_component_close(ffp, is->audio_stream); + change_stream = 1; + } break; case AVMEDIA_TYPE_SUBTITLE: - if (stream != is->subtitle_stream && is->subtitle_stream >= 0) + if (stream != is->subtitle_stream && is->subtitle_stream >= 0) { stream_component_close(ffp, is->subtitle_stream); + change_stream = 1; + } break; default: av_log(ffp, AV_LOG_ERROR, "select invalid stream %d of video type %d\n", stream, codecpar->codec_type); return -1; } - return stream_component_open(ffp, stream); + if (change_stream) { + int ret = stream_component_open(ffp, stream); + ffp_seek_to_l(ffp, current_pos); + return ret; + } else { + return 0; + } } else { switch (codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: From 78e3789ad09cdbb15baed00ac360a924ed2b71fc Mon Sep 17 00:00:00 2001 From: xufulong Date: Fri, 3 Dec 2021 20:38:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0stream=20index=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=88=87=E6=8D=A2stream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ijkmedia/ijkplayer/ijkmeta.c | 1 + ijkmedia/ijkplayer/ijkmeta.h | 1 + 2 files changed, 2 insertions(+) diff --git a/ijkmedia/ijkplayer/ijkmeta.c b/ijkmedia/ijkplayer/ijkmeta.c index 10380b809b..b699139c67 100755 --- a/ijkmedia/ijkplayer/ijkmeta.c +++ b/ijkmedia/ijkplayer/ijkmeta.c @@ -227,6 +227,7 @@ void ijkmeta_set_avformat_context_l(IjkMediaMeta *meta, AVFormatContext *ic) if (bitrate > 0) { ijkmeta_set_int64_l(stream_meta, IJKM_KEY_BITRATE, bitrate); } + ijkmeta_set_int64_l(stream_meta, IJKM_KEY_STREAM_INDEX, st->index); switch (codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: { diff --git a/ijkmedia/ijkplayer/ijkmeta.h b/ijkmedia/ijkplayer/ijkmeta.h index 4334b2ffdc..8a0b4a6773 100755 --- a/ijkmedia/ijkplayer/ijkmeta.h +++ b/ijkmedia/ijkplayer/ijkmeta.h @@ -43,6 +43,7 @@ #define IJKM_VAL_TYPE__TIMEDTEXT "timedtext" #define IJKM_VAL_TYPE__UNKNOWN "unknown" #define IJKM_KEY_LANGUAGE "language" +#define IJKM_KEY_STREAM_INDEX "index" #define IJKM_KEY_CODEC_NAME "codec_name" #define IJKM_KEY_CODEC_PROFILE "codec_profile" From fbe0d2da7af5e3fe91298340dc75543b513bd794 Mon Sep 17 00:00:00 2001 From: xufulong Date: Thu, 9 Dec 2021 11:38:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=9B=B8=E5=90=8Cstream?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=81=9A=E5=A4=84=E7=90=86=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ijkmedia/ijkplayer/ff_ffplay.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/ijkmedia/ijkplayer/ff_ffplay.c b/ijkmedia/ijkplayer/ff_ffplay.c index 2cd8bc29bd..8daf863077 100755 --- a/ijkmedia/ijkplayer/ff_ffplay.c +++ b/ijkmedia/ijkplayer/ff_ffplay.c @@ -4837,7 +4837,6 @@ int ffp_set_stream_selected(FFPlayer *ffp, int stream, int selected) VideoState *is = ffp->is; AVFormatContext *ic = NULL; AVCodecParameters *codecpar = NULL; - int change_stream = 0; if (!is || !is->ic) return -1; @@ -4851,36 +4850,30 @@ int ffp_set_stream_selected(FFPlayer *ffp, int stream, int selected) long current_pos = ffp_get_current_position_l(ffp); if (selected) { + if (stream == is->video_stream || stream == is->audio_stream || stream == is->subtitle_stream) { + av_log(ffp, AV_LOG_ERROR, "stream has been selected\n"); + return 0; + } switch (codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: - if (stream != is->video_stream && is->video_stream >= 0) { + if (stream != is->video_stream && is->video_stream >= 0) stream_component_close(ffp, is->video_stream); - change_stream = 1; - } break; case AVMEDIA_TYPE_AUDIO: - if (stream != is->audio_stream && is->audio_stream >= 0) { + if (stream != is->audio_stream && is->audio_stream >= 0) stream_component_close(ffp, is->audio_stream); - change_stream = 1; - } break; case AVMEDIA_TYPE_SUBTITLE: - if (stream != is->subtitle_stream && is->subtitle_stream >= 0) { + if (stream != is->subtitle_stream && is->subtitle_stream >= 0) stream_component_close(ffp, is->subtitle_stream); - change_stream = 1; - } break; default: av_log(ffp, AV_LOG_ERROR, "select invalid stream %d of video type %d\n", stream, codecpar->codec_type); return -1; } - if (change_stream) { - int ret = stream_component_open(ffp, stream); - ffp_seek_to_l(ffp, current_pos); - return ret; - } else { - return 0; - } + int ret = stream_component_open(ffp, stream); + ffp_seek_to_l(ffp, current_pos); + return ret; } else { switch (codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: @@ -4896,7 +4889,7 @@ int ffp_set_stream_selected(FFPlayer *ffp, int stream, int selected) stream_component_close(ffp, is->subtitle_stream); break; default: - av_log(ffp, AV_LOG_ERROR, "select invalid stream %d of audio type %d\n", stream, codecpar->codec_type); + av_log(ffp, AV_LOG_ERROR, "unselect invalid stream %d of audio type %d\n", stream, codecpar->codec_type); return -1; } return 0; From 221712c9f829f985b8f4eb87bbf7d829e774b9cb Mon Sep 17 00:00:00 2001 From: xufulong Date: Tue, 14 Dec 2021 18:24:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=A1=A5=E5=85=85language,=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E9=9F=B3=E8=BD=A8=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IJKMediaPlayer/IJKFFMoviePlayerController.h | 2 ++ .../IJKMediaPlayer/IJKFFMoviePlayerController.m | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.h b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.h index 004c123aa5..8e972cf06a 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.h +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.h @@ -41,6 +41,8 @@ #define k_IJKM_KEY_CODEC_NAME @"codec_name" #define k_IJKM_KEY_CODEC_PROFILE @"codec_profile" #define k_IJKM_KEY_CODEC_LONG_NAME @"codec_long_name" +#define k_IJKM_KEY_LANGUAGE @"language" +#define k_IJKM_KEY_STREAM_INDEX @"index" // stream: video #define k_IJKM_KEY_WIDTH @"width" diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m index 957e8a56df..ebd38fddb5 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m @@ -1091,6 +1091,7 @@ - (void)postEvent: (IJKFFMoviePlayerMessage *)msg fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_CODEC_PROFILE, nil); fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_CODEC_LONG_NAME, nil); fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_BITRATE, nil); + fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_STREAM_INDEX, nil); if (0 == strcmp(type, IJKM_VAL_TYPE__VIDEO)) { fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_WIDTH, nil); @@ -1116,10 +1117,13 @@ - (void)postEvent: (IJKFFMoviePlayerMessage *)msg } else if (0 == strcmp(type, IJKM_VAL_TYPE__AUDIO)) { fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_SAMPLE_RATE, nil); fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_CHANNEL_LAYOUT, nil); + fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_LANGUAGE, nil); if (audio_stream == i) { _monitor.audioMeta = streamMeta; } + } else if (0 == strcmp(type, IJKM_VAL_TYPE__TIMEDTEXT)) { + fillMetaInternal(streamMeta, streamRawMeta, IJKM_KEY_LANGUAGE, nil); } } }