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

Side by Side Diff: content/renderer/media/media_recorder_handler.cc

Issue 2623353004: RELAND: MediaRecorder: use VideoTrackRecorder::GetPreferredCodecId() when available (Closed)
Patch Set: Avoid H264 if !BUILDFLAG(RTC_USE_H264) 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
OLDNEW
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/media_recorder_handler.h" 5 #include "content/renderer/media/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
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 case VideoTrackRecorder::CodecId::H264: 44 case VideoTrackRecorder::CodecId::H264:
44 return media::kCodecH264; 45 return media::kCodecH264;
46 #endif
47 case VideoTrackRecorder::CodecId::LAST:
48 return media::kUnknownVideoCodec;
45 } 49 }
46 NOTREACHED() << "Unsupported codec"; 50 NOTREACHED() << "Unsupported codec";
47 return media::kUnknownVideoCodec; 51 return media::kUnknownVideoCodec;
48 } 52 }
49 53
50 } // anonymous namespace 54 } // anonymous namespace
51 55
52 MediaRecorderHandler::MediaRecorderHandler() 56 MediaRecorderHandler::MediaRecorderHandler()
53 : video_bits_per_second_(0), 57 : video_bits_per_second_(0),
54 audio_bits_per_second_(0), 58 audio_bits_per_second_(0),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const blink::WebString& type, 116 const blink::WebString& type,
113 const blink::WebString& codecs, 117 const blink::WebString& codecs,
114 int32_t audio_bits_per_second, 118 int32_t audio_bits_per_second,
115 int32_t video_bits_per_second) { 119 int32_t video_bits_per_second) {
116 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 120 DCHECK(main_render_thread_checker_.CalledOnValidThread());
117 // Save histogram data so we can see how much MediaStream Recorder is used. 121 // Save histogram data so we can see how much MediaStream Recorder is used.
118 // The histogram counts the number of calls to the JS API. 122 // The histogram counts the number of calls to the JS API.
119 UpdateWebRTCMethodCount(WEBKIT_MEDIA_STREAM_RECORDER); 123 UpdateWebRTCMethodCount(WEBKIT_MEDIA_STREAM_RECORDER);
120 124
121 if (!canSupportMimeType(type, codecs)) { 125 if (!canSupportMimeType(type, codecs)) {
122 DLOG(ERROR) << "Can't support " << type.utf8() 126 DLOG(ERROR) << "Unsupported " << type.utf8() << ";codecs=" << codecs.utf8();
123 << ";codecs=" << codecs.utf8();
124 return false; 127 return false;
125 } 128 }
126 129
127 // Once established that we support the codec(s), hunt then individually. 130 // Once established that we support the codec(s), hunt then individually.
128 const std::string& codecs_str = ToLowerASCII(codecs.utf8()); 131 const std::string& codecs_str = ToLowerASCII(codecs.utf8());
129 if (codecs_str.find("vp8") != std::string::npos) 132 if (codecs_str.find("vp8") != std::string::npos)
130 codec_id_ = VideoTrackRecorder::CodecId::VP8; 133 codec_id_ = VideoTrackRecorder::CodecId::VP8;
131 else if (codecs_str.find("vp9") != std::string::npos) 134 else if (codecs_str.find("vp9") != std::string::npos)
132 codec_id_ = VideoTrackRecorder::CodecId::VP9; 135 codec_id_ = VideoTrackRecorder::CodecId::VP9;
133 #if BUILDFLAG(RTC_USE_H264) 136 #if BUILDFLAG(RTC_USE_H264)
134 else if (codecs_str.find("h264") != std::string::npos) 137 else if (codecs_str.find("h264") != std::string::npos)
135 codec_id_ = VideoTrackRecorder::CodecId::H264; 138 codec_id_ = VideoTrackRecorder::CodecId::H264;
136 else if (codecs_str.find("avc1") != std::string::npos) 139 else if (codecs_str.find("avc1") != std::string::npos)
137 codec_id_ = VideoTrackRecorder::CodecId::H264; 140 codec_id_ = VideoTrackRecorder::CodecId::H264;
138 #endif 141 #endif
142 else
143 codec_id_ = VideoTrackRecorder::GetPreferredCodecId();
144
145 DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id "
146 << static_cast<int>(codec_id_);
139 147
140 media_stream_ = media_stream; 148 media_stream_ = media_stream;
141 DCHECK(client); 149 DCHECK(client);
142 client_ = client; 150 client_ = client;
143 151
144 audio_bits_per_second_ = audio_bits_per_second; 152 audio_bits_per_second_ = audio_bits_per_second;
145 video_bits_per_second_ = video_bits_per_second; 153 video_bits_per_second_ = video_bits_per_second;
146 return true; 154 return true;
147 } 155 }
148 156
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 recorder->OnData(audio_bus, timestamp); 319 recorder->OnData(audio_bus, timestamp);
312 } 320 }
313 321
314 void MediaRecorderHandler::SetAudioFormatForTesting( 322 void MediaRecorderHandler::SetAudioFormatForTesting(
315 const media::AudioParameters& params) { 323 const media::AudioParameters& params) {
316 for (const auto& recorder : audio_recorders_) 324 for (const auto& recorder : audio_recorders_)
317 recorder->OnSetFormat(params); 325 recorder->OnSetFormat(params);
318 } 326 }
319 327
320 } // namespace content 328 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_media_recorder_browsertest.cc ('k') | content/renderer/media/video_track_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698