OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/media_recorder/media_recorder_handler.h" | 5 #include "content/renderer/media_recorder/media_recorder_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 using blink::WebMediaCapabilitiesQueryCallbacks; | 37 using blink::WebMediaCapabilitiesQueryCallbacks; |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { | 41 media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { |
42 switch (id) { | 42 switch (id) { |
43 case VideoTrackRecorder::CodecId::VP8: | 43 case VideoTrackRecorder::CodecId::VP8: |
44 return media::kCodecVP8; | 44 return media::kCodecVP8; |
45 case VideoTrackRecorder::CodecId::VP9: | 45 case VideoTrackRecorder::CodecId::VP9: |
46 return media::kCodecVP9; | 46 return media::kCodecVP9; |
47 #if defined(IS_H264_SUPPORTED) | 47 #if BUILDFLAG(RTC_USE_H264) |
48 case VideoTrackRecorder::CodecId::H264: | 48 case VideoTrackRecorder::CodecId::H264: |
49 return media::kCodecH264; | 49 return media::kCodecH264; |
50 #endif | 50 #endif |
51 case VideoTrackRecorder::CodecId::LAST: | 51 case VideoTrackRecorder::CodecId::LAST: |
52 return media::kUnknownVideoCodec; | 52 return media::kUnknownVideoCodec; |
53 } | 53 } |
54 NOTREACHED() << "Unsupported codec"; | 54 NOTREACHED() << "Unsupported codec"; |
55 return media::kUnknownVideoCodec; | 55 return media::kUnknownVideoCodec; |
56 } | 56 } |
57 | 57 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DLOG(ERROR) << "Unsupported " << type.Utf8() << ";codecs=" << codecs.Utf8(); | 135 DLOG(ERROR) << "Unsupported " << type.Utf8() << ";codecs=" << codecs.Utf8(); |
136 return false; | 136 return false; |
137 } | 137 } |
138 | 138 |
139 // Once established that we support the codec(s), hunt then individually. | 139 // Once established that we support the codec(s), hunt then individually. |
140 const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); | 140 const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); |
141 if (codecs_str.find("vp8") != std::string::npos) | 141 if (codecs_str.find("vp8") != std::string::npos) |
142 codec_id_ = VideoTrackRecorder::CodecId::VP8; | 142 codec_id_ = VideoTrackRecorder::CodecId::VP8; |
143 else if (codecs_str.find("vp9") != std::string::npos) | 143 else if (codecs_str.find("vp9") != std::string::npos) |
144 codec_id_ = VideoTrackRecorder::CodecId::VP9; | 144 codec_id_ = VideoTrackRecorder::CodecId::VP9; |
145 #if defined(IS_H264_SUPPORTED) | 145 #if BUILDFLAG(RTC_USE_H264) |
146 else if (codecs_str.find("h264") != std::string::npos) | 146 else if (codecs_str.find("h264") != std::string::npos) |
147 codec_id_ = VideoTrackRecorder::CodecId::H264; | 147 codec_id_ = VideoTrackRecorder::CodecId::H264; |
148 else if (codecs_str.find("avc1") != std::string::npos) | 148 else if (codecs_str.find("avc1") != std::string::npos) |
149 codec_id_ = VideoTrackRecorder::CodecId::H264; | 149 codec_id_ = VideoTrackRecorder::CodecId::H264; |
150 #endif | 150 #endif |
151 else | 151 else |
152 codec_id_ = VideoTrackRecorder::GetPreferredCodecId(); | 152 codec_id_ = VideoTrackRecorder::GetPreferredCodecId(); |
153 | 153 |
154 DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id " | 154 DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id " |
155 << static_cast<int>(codec_id_); | 155 << static_cast<int>(codec_id_); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 recorder->OnData(audio_bus, timestamp); | 432 recorder->OnData(audio_bus, timestamp); |
433 } | 433 } |
434 | 434 |
435 void MediaRecorderHandler::SetAudioFormatForTesting( | 435 void MediaRecorderHandler::SetAudioFormatForTesting( |
436 const media::AudioParameters& params) { | 436 const media::AudioParameters& params) { |
437 for (const auto& recorder : audio_recorders_) | 437 for (const auto& recorder : audio_recorders_) |
438 recorder->OnSetFormat(params); | 438 recorder->OnSetFormat(params); |
439 } | 439 } |
440 | 440 |
441 } // namespace content | 441 } // namespace content |
OLD | NEW |