Skip to content

Commit

Permalink
lavf: merge utils-mythtv.c back into utils.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ulmus-scott committed Jun 14, 2022
1 parent aec092b commit 4445b96
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 92 deletions.
1 change: 0 additions & 1 deletion mythtv/external/FFmpeg/libavformat/Makefile
Expand Up @@ -21,7 +21,6 @@ OBJS = allformats.o \
sdp.o \
url.o \
utils.o \
utils-mythtv.o \

OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o

Expand Down
91 changes: 0 additions & 91 deletions mythtv/external/FFmpeg/libavformat/utils-mythtv.c

This file was deleted.

68 changes: 68 additions & 0 deletions mythtv/external/FFmpeg/libavformat/utils.c
Expand Up @@ -5931,3 +5931,71 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}

/**
* @brief Remove a stream from a media stream.
*
* This is used by mpegts, so we can track streams as indicated by the PMT.
*
* @param s MPEG media stream handle
* @param id stream id of stream to remove
* @param remove_ts if true, remove any matching MPEG-TS filter as well
*/
void av_remove_stream(AVFormatContext *s, int id, int remove_ts) {
int i;
int changes = 0;

for (i=0; i<s->nb_streams; i++) {
if (s->streams[i]->id != id)
continue;

av_log(NULL, AV_LOG_DEBUG, "av_remove_stream 0x%x\n", id);

/* close codec context */
AVCodecContext *codec_ctx = s->streams[i]->codec;
if (codec_ctx->codec) {
avcodec_close(codec_ctx);
av_free(codec_ctx);
}
#if 0
/* make sure format context is not using the codec context */
if (&s->streams[i] == s->cur_st) {
av_log(NULL, AV_LOG_DEBUG, "av_remove_stream cur_st = NULL\n");
s->cur_st = NULL;
}
#endif
/* else if (s->cur_st > &s->streams[i]) {
av_log(NULL, AV_LOG_DEBUG, "av_remove_stream cur_st -= 1\n");
s->cur_st -= sizeof(AVFormatContext *);
} */
else {
av_log(NULL, AV_LOG_DEBUG,
"av_remove_stream: no change to cur_st\n");
}

av_log(NULL, AV_LOG_DEBUG, "av_remove_stream: removing... "
"s->nb_streams=%d i=%d\n", s->nb_streams, i);
/* actually remove av stream */
s->nb_streams--;
if ((s->nb_streams - i) > 0) {
memmove(&s->streams[i], &s->streams[i+1],
(s->nb_streams-i)*sizeof(AVFormatContext *));
}
else
s->streams[i] = NULL;

changes = 1;
}
if (changes)
{
// flush queued packets after a stream change (might need to make smarter)
flush_packet_queue(s);

/* renumber the streams */
av_log(NULL, AV_LOG_DEBUG, "av_remove_stream: renumbering streams\n");
for (i=0; i<s->nb_streams; i++)
s->streams[i]->index=i;
}

(void)remove_ts;
}

0 comments on commit 4445b96

Please sign in to comment.