OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/media/rtc_encoding_video_capturer_factory.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/logging.h" | |
9 #include "base/stl_util.h" | |
10 #include "content/renderer/media/rtc_encoding_video_capturer.h" | |
11 #include "media/base/encoded_bitstream_buffer.h" | |
12 | |
13 namespace content { | |
14 | |
15 RtcEncodingVideoCapturerFactory::RtcEncodingVideoCapturerFactory() | |
16 : encoded_video_source_(NULL) { | |
17 } | |
18 | |
19 RtcEncodingVideoCapturerFactory::~RtcEncodingVideoCapturerFactory() { | |
20 STLDeleteElements(&encoder_set_); | |
Ami GONE FROM CHROMIUM
2013/06/12 01:44:06
I'm surprised you need to delete these explicitly
hshi1
2013/06/12 17:52:39
Done.
| |
21 } | |
22 | |
23 void RtcEncodingVideoCapturerFactory::OnEncodedVideoSourceAdded( | |
24 media::EncodedVideoSource* source) { | |
25 // TODO(hshi): support multiple encoded video sources. | |
26 // For now we only support one instance of encoded video source at a time. | |
27 DCHECK(!encoded_video_source_); | |
28 encoded_video_source_ = source; | |
29 source->RequestCapabilities(base::Bind( | |
30 &RtcEncodingVideoCapturerFactory::OnCapabilitiesAvailable, this)); | |
31 } | |
32 | |
33 void RtcEncodingVideoCapturerFactory::OnEncodedVideoSourceRemoved( | |
34 media::EncodedVideoSource* source) { | |
35 encoded_video_source_ = NULL; | |
36 } | |
37 | |
38 webrtc::VideoEncoder* RtcEncodingVideoCapturerFactory::CreateVideoEncoder( | |
39 webrtc::VideoCodecType type) { | |
40 for (size_t i = 0; i < codecs_.size(); ++i) { | |
41 if (codecs_[i].type == type) { | |
42 RtcEncodingVideoCapturer* capturer = | |
43 new RtcEncodingVideoCapturer(encoded_video_source_, type); | |
44 encoder_set_.insert(capturer); | |
45 return capturer; | |
46 } | |
47 } | |
48 return NULL; | |
49 } | |
50 | |
51 void RtcEncodingVideoCapturerFactory::DestroyVideoEncoder( | |
52 webrtc::VideoEncoder* encoder) { | |
53 EncoderSet::iterator it = encoder_set_.find(encoder); | |
54 if (it != encoder_set_.end()) { | |
55 delete encoder; | |
56 encoder_set_.erase(it); | |
57 } | |
58 } | |
59 | |
60 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& | |
61 RtcEncodingVideoCapturerFactory::codecs() const { | |
62 return codecs_; | |
63 } | |
64 | |
65 void RtcEncodingVideoCapturerFactory::OnCapabilitiesAvailable( | |
66 const media::VideoEncodingCapabilities& caps) { | |
67 codecs_.clear(); | |
68 | |
69 for (size_t i = 0; i < caps.size(); ++i) { | |
70 webrtc::VideoCodecType webrtc_codec_type = webrtc::kVideoCodecGeneric; | |
71 switch (caps[i].codec_type) { | |
72 case media::kCodecVP8: | |
73 webrtc_codec_type = webrtc::kVideoCodecVP8; | |
74 break; | |
75 default: | |
76 break; | |
77 } | |
78 codecs_.push_back(cricket::WebRtcVideoEncoderFactory::VideoCodec( | |
79 webrtc_codec_type, | |
80 caps[i].codec_name, | |
81 caps[i].max_resolution.width(), | |
82 caps[i].max_resolution.height(), | |
83 caps[i].max_frames_per_second)); | |
84 } | |
85 } | |
86 | |
87 } // namespace content | |
OLD | NEW |