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

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

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