| OLD | NEW | 
|     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 #include "media/filters/ffmpeg_demuxer.h" |     5 #include "media/filters/ffmpeg_demuxer.h" | 
|     6  |     6  | 
|     7 #include <algorithm> |     7 #include <algorithm> | 
|     8 #include <memory> |     8 #include <memory> | 
|     9 #include <set> |     9 #include <set> | 
|    10 #include <utility> |    10 #include <utility> | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    42 #include "media/filters/webvtt_util.h" |    42 #include "media/filters/webvtt_util.h" | 
|    43 #include "media/formats/webm/webm_crypto_helpers.h" |    43 #include "media/formats/webm/webm_crypto_helpers.h" | 
|    44 #include "media/media_features.h" |    44 #include "media/media_features.h" | 
|    45  |    45  | 
|    46 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |    46 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 
|    47 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" |    47 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" | 
|    48 #endif |    48 #endif | 
|    49  |    49  | 
|    50 namespace media { |    50 namespace media { | 
|    51  |    51  | 
 |    52 namespace { | 
 |    53  | 
 |    54 void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) { | 
 |    55   DCHECK(stream); | 
 |    56   stream->discard = discard; | 
 |    57 } | 
 |    58  | 
 |    59 }  // namespace | 
 |    60  | 
|    52 static base::Time ExtractTimelineOffset(AVFormatContext* format_context) { |    61 static base::Time ExtractTimelineOffset(AVFormatContext* format_context) { | 
|    53   if (strstr(format_context->iformat->name, "webm") || |    62   if (strstr(format_context->iformat->name, "webm") || | 
|    54       strstr(format_context->iformat->name, "matroska")) { |    63       strstr(format_context->iformat->name, "matroska")) { | 
|    55     const AVDictionaryEntry* entry = |    64     const AVDictionaryEntry* entry = | 
|    56         av_dict_get(format_context->metadata, "creation_time", NULL, 0); |    65         av_dict_get(format_context->metadata, "creation_time", NULL, 0); | 
|    57  |    66  | 
|    58     base::Time timeline_offset; |    67     base::Time timeline_offset; | 
|    59  |    68  | 
|    60     // FFmpegDemuxerTests assume base::Time::FromUTCString() is used here. |    69     // FFmpegDemuxerTests assume base::Time::FromUTCString() is used here. | 
|    61     if (entry != NULL && entry->value != NULL && |    70     if (entry != NULL && entry->value != NULL && | 
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   729   return video_rotation_; |   738   return video_rotation_; | 
|   730 } |   739 } | 
|   731  |   740  | 
|   732 bool FFmpegDemuxerStream::IsEnabled() const { |   741 bool FFmpegDemuxerStream::IsEnabled() const { | 
|   733   DCHECK(task_runner_->BelongsToCurrentThread()); |   742   DCHECK(task_runner_->BelongsToCurrentThread()); | 
|   734   return is_enabled_; |   743   return is_enabled_; | 
|   735 } |   744 } | 
|   736  |   745  | 
|   737 void FFmpegDemuxerStream::SetEnabled(bool enabled, base::TimeDelta timestamp) { |   746 void FFmpegDemuxerStream::SetEnabled(bool enabled, base::TimeDelta timestamp) { | 
|   738   DCHECK(task_runner_->BelongsToCurrentThread()); |   747   DCHECK(task_runner_->BelongsToCurrentThread()); | 
 |   748   DCHECK(demuxer_); | 
 |   749   DCHECK(demuxer_->ffmpeg_task_runner()); | 
|   739   if (enabled == is_enabled_) |   750   if (enabled == is_enabled_) | 
|   740     return; |   751     return; | 
|   741  |   752  | 
|   742   is_enabled_ = enabled; |   753   is_enabled_ = enabled; | 
|   743   av_stream()->discard = enabled ? AVDISCARD_DEFAULT : AVDISCARD_ALL; |   754   demuxer_->ffmpeg_task_runner()->PostTask( | 
 |   755       FROM_HERE, base::Bind(&SetAVStreamDiscard, av_stream(), | 
 |   756                             enabled ? AVDISCARD_DEFAULT : AVDISCARD_ALL)); | 
|   744   if (is_enabled_) { |   757   if (is_enabled_) { | 
|   745     waiting_for_keyframe_ = true; |   758     waiting_for_keyframe_ = true; | 
|   746   } |   759   } | 
|   747   if (!is_enabled_ && !read_cb_.is_null()) { |   760   if (!is_enabled_ && !read_cb_.is_null()) { | 
|   748     DVLOG(1) << "Read from disabled stream, returning EOS"; |   761     DVLOG(1) << "Read from disabled stream, returning EOS"; | 
|   749     base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); |   762     base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); | 
|   750   } |   763   } | 
|   751   if (!stream_status_change_cb_.is_null()) |   764   if (!stream_status_change_cb_.is_null()) | 
|   752     stream_status_change_cb_.Run(this, is_enabled_, timestamp); |   765     stream_status_change_cb_.Run(this, is_enabled_, timestamp); | 
|   753 } |   766 } | 
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1868  |  1881  | 
|  1869 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |  1882 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 
|  1870   DCHECK(task_runner_->BelongsToCurrentThread()); |  1883   DCHECK(task_runner_->BelongsToCurrentThread()); | 
|  1871   for (const auto& stream : streams_) { |  1884   for (const auto& stream : streams_) { | 
|  1872     if (stream) |  1885     if (stream) | 
|  1873       stream->SetLiveness(liveness); |  1886       stream->SetLiveness(liveness); | 
|  1874   } |  1887   } | 
|  1875 } |  1888 } | 
|  1876  |  1889  | 
|  1877 }  // namespace media |  1890 }  // namespace media | 
| OLD | NEW |