Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 2643333002: Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 if (waiting_for_keyframe_) { 365 if (waiting_for_keyframe_) {
366 if (packet.get()->flags & AV_PKT_FLAG_KEY) 366 if (packet.get()->flags & AV_PKT_FLAG_KEY)
367 waiting_for_keyframe_ = false; 367 waiting_for_keyframe_ = false;
368 else { 368 else {
369 DVLOG(3) << "Dropped non-keyframe pts=" << packet->pts; 369 DVLOG(3) << "Dropped non-keyframe pts=" << packet->pts;
370 return; 370 return;
371 } 371 }
372 } 372 }
373 373
374 #if defined(USE_PROPRIETARY_CODECS) 374 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
375 // Convert the packet if there is a bitstream filter. 375 // Convert the packet if there is a bitstream filter.
376 if (packet->data && bitstream_converter_ && 376 if (packet->data && bitstream_converter_ &&
377 !bitstream_converter_->ConvertPacket(packet.get())) { 377 !bitstream_converter_->ConvertPacket(packet.get())) {
378 LOG(ERROR) << "Format conversion failed."; 378 LOG(ERROR) << "Format conversion failed.";
379 } 379 }
380 #endif 380 #endif
381 381
382 // Get side data if any. For now, the only type of side_data is VP8 Alpha. We 382 // Get side data if any. For now, the only type of side_data is VP8 Alpha. We
383 // keep this generic so that other side_data types in the future can be 383 // keep this generic so that other side_data types in the future can be
384 // handled the same way as well. 384 // handled the same way as well.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 base::ResetAndReturn(&read_cb_).Run(kAborted, nullptr); 645 base::ResetAndReturn(&read_cb_).Run(kAborted, nullptr);
646 return; 646 return;
647 } 647 }
648 648
649 SatisfyPendingRead(); 649 SatisfyPendingRead();
650 } 650 }
651 651
652 void FFmpegDemuxerStream::EnableBitstreamConverter() { 652 void FFmpegDemuxerStream::EnableBitstreamConverter() {
653 DCHECK(task_runner_->BelongsToCurrentThread()); 653 DCHECK(task_runner_->BelongsToCurrentThread());
654 654
655 #if defined(USE_PROPRIETARY_CODECS) 655 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
656 InitBitstreamConverter(); 656 InitBitstreamConverter();
657 #else 657 #else
658 NOTREACHED() << "Proprietary codecs not enabled."; 658 NOTREACHED() << "Proprietary codecs not enabled.";
659 #endif 659 #endif
660 } 660 }
661 661
662 void FFmpegDemuxerStream::ResetBitstreamConverter() { 662 void FFmpegDemuxerStream::ResetBitstreamConverter() {
663 #if defined(USE_PROPRIETARY_CODECS) 663 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
664 if (bitstream_converter_) 664 if (bitstream_converter_)
665 InitBitstreamConverter(); 665 InitBitstreamConverter();
666 #endif // defined(USE_PROPRIETARY_CODECS) 666 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
667 } 667 }
668 668
669 void FFmpegDemuxerStream::InitBitstreamConverter() { 669 void FFmpegDemuxerStream::InitBitstreamConverter() {
670 #if defined(USE_PROPRIETARY_CODECS) 670 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
671 switch (stream_->codecpar->codec_id) { 671 switch (stream_->codecpar->codec_id) {
672 case AV_CODEC_ID_H264: 672 case AV_CODEC_ID_H264:
673 // Clear |extra_data| so that future (fallback) decoders will know that 673 // Clear |extra_data| so that future (fallback) decoders will know that
674 // conversion is forcibly enabled on this stream. 674 // conversion is forcibly enabled on this stream.
675 // 675 //
676 // TODO(sandersd): Ideally we would convert |extra_data| to concatenated 676 // TODO(sandersd): Ideally we would convert |extra_data| to concatenated
677 // SPS/PPS data, but it's too late to be useful because Initialize() was 677 // SPS/PPS data, but it's too late to be useful because Initialize() was
678 // already called on GpuVideoDecoder, which is the only path that would 678 // already called on GpuVideoDecoder, which is the only path that would
679 // consume that data. 679 // consume that data.
680 if (video_config_) 680 if (video_config_)
681 video_config_->SetExtraData(std::vector<uint8_t>()); 681 video_config_->SetExtraData(std::vector<uint8_t>());
682 bitstream_converter_.reset( 682 bitstream_converter_.reset(
683 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codecpar)); 683 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codecpar));
684 break; 684 break;
685 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 685 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
686 case AV_CODEC_ID_HEVC: 686 case AV_CODEC_ID_HEVC:
687 bitstream_converter_.reset( 687 bitstream_converter_.reset(
688 new FFmpegH265ToAnnexBBitstreamConverter(stream_->codecpar)); 688 new FFmpegH265ToAnnexBBitstreamConverter(stream_->codecpar));
689 break; 689 break;
690 #endif 690 #endif
691 case AV_CODEC_ID_AAC: 691 case AV_CODEC_ID_AAC:
692 bitstream_converter_.reset( 692 bitstream_converter_.reset(
693 new FFmpegAACBitstreamConverter(stream_->codecpar)); 693 new FFmpegAACBitstreamConverter(stream_->codecpar));
694 break; 694 break;
695 default: 695 default:
696 break; 696 break;
697 } 697 }
698 #endif // defined(USE_PROPRIETARY_CODECS) 698 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
699 } 699 }
700 700
701 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; } 701 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; }
702 702
703 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() { 703 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() {
704 DCHECK(task_runner_->BelongsToCurrentThread()); 704 DCHECK(task_runner_->BelongsToCurrentThread());
705 DCHECK_EQ(type_, AUDIO); 705 DCHECK_EQ(type_, AUDIO);
706 DCHECK(audio_config_.get()); 706 DCHECK(audio_config_.get());
707 return *audio_config_; 707 return *audio_config_;
708 } 708 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 1808
1809 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1809 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1810 DCHECK(task_runner_->BelongsToCurrentThread()); 1810 DCHECK(task_runner_->BelongsToCurrentThread());
1811 for (const auto& stream : streams_) { 1811 for (const auto& stream : streams_) {
1812 if (stream) 1812 if (stream)
1813 stream->SetLiveness(liveness); 1813 stream->SetLiveness(liveness);
1814 } 1814 }
1815 } 1815 }
1816 1816
1817 } // namespace media 1817 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698