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

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

Issue 2572883002: Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Merge Created 4 years 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 base::ResetAndReturn(&read_cb_).Run(kAborted, nullptr); 648 base::ResetAndReturn(&read_cb_).Run(kAborted, nullptr);
649 return; 649 return;
650 } 650 }
651 651
652 SatisfyPendingRead(); 652 SatisfyPendingRead();
653 } 653 }
654 654
655 void FFmpegDemuxerStream::EnableBitstreamConverter() { 655 void FFmpegDemuxerStream::EnableBitstreamConverter() {
656 DCHECK(task_runner_->BelongsToCurrentThread()); 656 DCHECK(task_runner_->BelongsToCurrentThread());
657 657
658 #if defined(USE_PROPRIETARY_CODECS) 658 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
659 InitBitstreamConverter(); 659 InitBitstreamConverter();
660 #else 660 #else
661 NOTREACHED() << "Proprietary codecs not enabled."; 661 NOTREACHED() << "Proprietary codecs not enabled.";
662 #endif 662 #endif
663 } 663 }
664 664
665 void FFmpegDemuxerStream::ResetBitstreamConverter() { 665 void FFmpegDemuxerStream::ResetBitstreamConverter() {
666 #if defined(USE_PROPRIETARY_CODECS) 666 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
667 if (bitstream_converter_) 667 if (bitstream_converter_)
668 InitBitstreamConverter(); 668 InitBitstreamConverter();
669 #endif // defined(USE_PROPRIETARY_CODECS) 669 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
670 } 670 }
671 671
672 void FFmpegDemuxerStream::InitBitstreamConverter() { 672 void FFmpegDemuxerStream::InitBitstreamConverter() {
673 #if defined(USE_PROPRIETARY_CODECS) 673 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
674 switch (stream_->codecpar->codec_id) { 674 switch (stream_->codecpar->codec_id) {
675 case AV_CODEC_ID_H264: 675 case AV_CODEC_ID_H264:
676 // Clear |extra_data| so that future (fallback) decoders will know that 676 // Clear |extra_data| so that future (fallback) decoders will know that
677 // conversion is forcibly enabled on this stream. 677 // conversion is forcibly enabled on this stream.
678 // 678 //
679 // TODO(sandersd): Ideally we would convert |extra_data| to concatenated 679 // TODO(sandersd): Ideally we would convert |extra_data| to concatenated
680 // SPS/PPS data, but it's too late to be useful because Initialize() was 680 // SPS/PPS data, but it's too late to be useful because Initialize() was
681 // already called on GpuVideoDecoder, which is the only path that would 681 // already called on GpuVideoDecoder, which is the only path that would
682 // consume that data. 682 // consume that data.
683 if (video_config_) 683 if (video_config_)
684 video_config_->SetExtraData(std::vector<uint8_t>()); 684 video_config_->SetExtraData(std::vector<uint8_t>());
685 bitstream_converter_.reset( 685 bitstream_converter_.reset(
686 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codecpar)); 686 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codecpar));
687 break; 687 break;
688 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 688 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
689 case AV_CODEC_ID_HEVC: 689 case AV_CODEC_ID_HEVC:
690 bitstream_converter_.reset( 690 bitstream_converter_.reset(
691 new FFmpegH265ToAnnexBBitstreamConverter(stream_->codecpar)); 691 new FFmpegH265ToAnnexBBitstreamConverter(stream_->codecpar));
692 break; 692 break;
693 #endif 693 #endif
694 case AV_CODEC_ID_AAC: 694 case AV_CODEC_ID_AAC:
695 bitstream_converter_.reset( 695 bitstream_converter_.reset(
696 new FFmpegAACBitstreamConverter(stream_->codecpar)); 696 new FFmpegAACBitstreamConverter(stream_->codecpar));
697 break; 697 break;
698 default: 698 default:
699 break; 699 break;
700 } 700 }
701 #endif // defined(USE_PROPRIETARY_CODECS) 701 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
702 } 702 }
703 703
704 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; } 704 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; }
705 705
706 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() { 706 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() {
707 DCHECK(task_runner_->BelongsToCurrentThread()); 707 DCHECK(task_runner_->BelongsToCurrentThread());
708 DCHECK_EQ(type_, AUDIO); 708 DCHECK_EQ(type_, AUDIO);
709 DCHECK(audio_config_.get()); 709 DCHECK(audio_config_.get());
710 return *audio_config_; 710 return *audio_config_;
711 } 711 }
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 1804
1805 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1805 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1806 DCHECK(task_runner_->BelongsToCurrentThread()); 1806 DCHECK(task_runner_->BelongsToCurrentThread());
1807 for (const auto& stream : streams_) { 1807 for (const auto& stream : streams_) {
1808 if (stream) 1808 if (stream)
1809 stream->SetLiveness(liveness); 1809 stream->SetLiveness(liveness);
1810 } 1810 }
1811 } 1811 }
1812 1812
1813 } // namespace media 1813 } // 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