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

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

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

Powered by Google App Engine
This is Rietveld 408576698