OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/rtc_video_encoder_factory.h" | 5 #include "content/renderer/media/rtc_video_encoder_factory.h" |
6 | 6 |
7 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" | 7 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" |
8 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" | |
9 #include "content/renderer/media/rtc_video_encoder.h" | 8 #include "content/renderer/media/rtc_video_encoder.h" |
9 #include "media/filters/gpu_video_accelerator_factories.h" | |
10 #include "media/video/video_encode_accelerator.h" | 10 #include "media/video/video_encode_accelerator.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Translate from media::VideoEncodeAccelerator::SupportedProfile to | 16 // Translate from media::VideoEncodeAccelerator::SupportedProfile to |
17 // cricket::WebRtcVideoEncoderFactory::VideoCodec | 17 // cricket::WebRtcVideoEncoderFactory::VideoCodec |
18 cricket::WebRtcVideoEncoderFactory::VideoCodec VEAToWebRTCCodec( | 18 cricket::WebRtcVideoEncoderFactory::VideoCodec VEAToWebRTCCodec( |
19 const media::VideoEncodeAccelerator::SupportedProfile& profile) { | 19 const media::VideoEncodeAccelerator::SupportedProfile& profile) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 case webrtc::kVideoCodecGeneric: | 52 case webrtc::kVideoCodecGeneric: |
53 return media::H264PROFILE_MAIN; | 53 return media::H264PROFILE_MAIN; |
54 default: | 54 default: |
55 return media::VIDEO_CODEC_PROFILE_UNKNOWN; | 55 return media::VIDEO_CODEC_PROFILE_UNKNOWN; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 } // anonymous namespace | 59 } // anonymous namespace |
60 | 60 |
61 RTCVideoEncoderFactory::RTCVideoEncoderFactory( | 61 RTCVideoEncoderFactory::RTCVideoEncoderFactory( |
62 const scoped_refptr<RendererGpuVideoAcceleratorFactories>& gpu_factories) | 62 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) |
63 : gpu_factories_(gpu_factories) { | 63 : gpu_factories_(gpu_factories) { |
64 // Query media::VideoEncodeAccelerator (statically) for our supported codecs. | 64 // Query media::VideoEncodeAccelerator (statically) for our supported codecs. |
65 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = | 65 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles = |
66 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles(); | 66 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles(); |
67 for (size_t i = 0; i < profiles.size(); ++i) { | 67 for (size_t i = 0; i < profiles.size(); ++i) { |
68 VideoCodec codec = VEAToWebRTCCodec(profiles[i]); | 68 VideoCodec codec = VEAToWebRTCCodec(profiles[i]); |
69 if (codec.type != webrtc::kVideoCodecUnknown) | 69 if (codec.type != webrtc::kVideoCodecUnknown) |
70 codecs_.push_back(codec); | 70 codecs_.push_back(codec); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} | 74 RTCVideoEncoderFactory::~RTCVideoEncoderFactory() {} |
75 | 75 |
76 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( | 76 webrtc::VideoEncoder* RTCVideoEncoderFactory::CreateVideoEncoder( |
77 webrtc::VideoCodecType type) { | 77 webrtc::VideoCodecType type) { |
78 bool found = false; | 78 bool found = false; |
79 for (size_t i = 0; i < codecs_.size(); ++i) { | 79 for (size_t i = 0; i < codecs_.size(); ++i) { |
80 if (codecs_[i].type == type) { | 80 if (codecs_[i].type == type) { |
81 found = true; | 81 found = true; |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 if (!found) | 85 if (!found) |
86 return NULL; | 86 return NULL; |
87 // GpuVideoAcceleratorFactories is not thread safe. It cannot be shared | 87 // GpuVideoAcceleratorFactories is not thread safe. It cannot be shared |
88 // by different encoders. Since we aren't running on the child thread and | 88 // by different encoders. Since we aren't running on the child thread and |
89 // cannot create a new factory, clone one instead. | 89 // cannot create a new factory, clone one instead. |
wuchengli
2013/10/16 07:43:17
Remove comment.
sheu
2013/10/21 05:17:35
Done.
| |
90 return new RTCVideoEncoder( | 90 return new RTCVideoEncoder( |
91 type, WebRTCCodecToVideoCodecProfile(type), gpu_factories_->Clone()); | 91 type, WebRTCCodecToVideoCodecProfile(type), gpu_factories_); |
92 } | 92 } |
93 | 93 |
94 void RTCVideoEncoderFactory::AddObserver(Observer* observer) { | 94 void RTCVideoEncoderFactory::AddObserver(Observer* observer) { |
95 // No-op: our codec list is populated on installation. | 95 // No-op: our codec list is populated on installation. |
96 } | 96 } |
97 | 97 |
98 void RTCVideoEncoderFactory::RemoveObserver(Observer* observer) {} | 98 void RTCVideoEncoderFactory::RemoveObserver(Observer* observer) {} |
99 | 99 |
100 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& | 100 const std::vector<cricket::WebRtcVideoEncoderFactory::VideoCodec>& |
101 RTCVideoEncoderFactory::codecs() const { | 101 RTCVideoEncoderFactory::codecs() const { |
102 return codecs_; | 102 return codecs_; |
103 } | 103 } |
104 | 104 |
105 void RTCVideoEncoderFactory::DestroyVideoEncoder( | 105 void RTCVideoEncoderFactory::DestroyVideoEncoder( |
106 webrtc::VideoEncoder* encoder) { | 106 webrtc::VideoEncoder* encoder) { |
107 delete encoder; | 107 delete encoder; |
108 } | 108 } |
109 | 109 |
110 } // namespace content | 110 } // namespace content |
OLD | NEW |