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 22 matching lines...) Expand all Loading... |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { | 37 media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { |
38 switch (id) { | 38 switch (id) { |
39 case VideoTrackRecorder::CodecId::VP8: | 39 case VideoTrackRecorder::CodecId::VP8: |
40 return media::kCodecVP8; | 40 return media::kCodecVP8; |
41 case VideoTrackRecorder::CodecId::VP9: | 41 case VideoTrackRecorder::CodecId::VP9: |
42 return media::kCodecVP9; | 42 return media::kCodecVP9; |
43 #if BUILDFLAG(RTC_USE_H264) | 43 #if defined(IS_H264_SUPPORTED) |
44 case VideoTrackRecorder::CodecId::H264: | 44 case VideoTrackRecorder::CodecId::H264: |
45 return media::kCodecH264; | 45 return media::kCodecH264; |
46 #endif | 46 #endif |
47 case VideoTrackRecorder::CodecId::LAST: | 47 case VideoTrackRecorder::CodecId::LAST: |
48 return media::kUnknownVideoCodec; | 48 return media::kUnknownVideoCodec; |
49 } | 49 } |
50 NOTREACHED() << "Unsupported codec"; | 50 NOTREACHED() << "Unsupported codec"; |
51 return media::kUnknownVideoCodec; | 51 return media::kUnknownVideoCodec; |
52 } | 52 } |
53 | 53 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 DLOG(ERROR) << "Unsupported " << type.Utf8() << ";codecs=" << codecs.Utf8(); | 126 DLOG(ERROR) << "Unsupported " << type.Utf8() << ";codecs=" << codecs.Utf8(); |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 // Once established that we support the codec(s), hunt then individually. | 130 // Once established that we support the codec(s), hunt then individually. |
131 const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); | 131 const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); |
132 if (codecs_str.find("vp8") != std::string::npos) | 132 if (codecs_str.find("vp8") != std::string::npos) |
133 codec_id_ = VideoTrackRecorder::CodecId::VP8; | 133 codec_id_ = VideoTrackRecorder::CodecId::VP8; |
134 else if (codecs_str.find("vp9") != std::string::npos) | 134 else if (codecs_str.find("vp9") != std::string::npos) |
135 codec_id_ = VideoTrackRecorder::CodecId::VP9; | 135 codec_id_ = VideoTrackRecorder::CodecId::VP9; |
136 #if BUILDFLAG(RTC_USE_H264) | 136 #if defined(IS_H264_SUPPORTED) |
137 else if (codecs_str.find("h264") != std::string::npos) | 137 else if (codecs_str.find("h264") != std::string::npos) |
138 codec_id_ = VideoTrackRecorder::CodecId::H264; | 138 codec_id_ = VideoTrackRecorder::CodecId::H264; |
139 else if (codecs_str.find("avc1") != std::string::npos) | 139 else if (codecs_str.find("avc1") != std::string::npos) |
140 codec_id_ = VideoTrackRecorder::CodecId::H264; | 140 codec_id_ = VideoTrackRecorder::CodecId::H264; |
141 #endif | 141 #endif |
142 else | 142 else |
143 codec_id_ = VideoTrackRecorder::GetPreferredCodecId(); | 143 codec_id_ = VideoTrackRecorder::GetPreferredCodecId(); |
144 | 144 |
145 DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id " | 145 DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id " |
146 << static_cast<int>(codec_id_); | 146 << static_cast<int>(codec_id_); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 recorder->OnData(audio_bus, timestamp); | 375 recorder->OnData(audio_bus, timestamp); |
376 } | 376 } |
377 | 377 |
378 void MediaRecorderHandler::SetAudioFormatForTesting( | 378 void MediaRecorderHandler::SetAudioFormatForTesting( |
379 const media::AudioParameters& params) { | 379 const media::AudioParameters& params) { |
380 for (const auto& recorder : audio_recorders_) | 380 for (const auto& recorder : audio_recorders_) |
381 recorder->OnSetFormat(params); | 381 recorder->OnSetFormat(params); |
382 } | 382 } |
383 | 383 |
384 } // namespace content | 384 } // namespace content |
OLD | NEW |