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
3 // found in the LICENSE file.
5 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h"
7 #include "base/logging.h"
11 int WebRtcToMediaPlaneType(webrtc::PlaneType type
) {
14 return media::VideoFrame::kYPlane
;
16 return media::VideoFrame::kUPlane
;
18 return media::VideoFrame::kVPlane
;
21 return media::VideoFrame::kMaxPlanes
;
24 } // anonymous namespace
26 WebRtcVideoFrameAdapter::WebRtcVideoFrameAdapter(
27 const scoped_refptr
<media::VideoFrame
>& frame
)
31 WebRtcVideoFrameAdapter::~WebRtcVideoFrameAdapter() {
34 int WebRtcVideoFrameAdapter::width() const {
35 return frame_
->visible_rect().width();
38 int WebRtcVideoFrameAdapter::height() const {
39 return frame_
->visible_rect().height();
42 const uint8_t* WebRtcVideoFrameAdapter::data(webrtc::PlaneType type
) const {
43 return frame_
->visible_data(WebRtcToMediaPlaneType(type
));
46 int WebRtcVideoFrameAdapter::stride(webrtc::PlaneType type
) const {
47 return frame_
->stride(WebRtcToMediaPlaneType(type
));
50 void* WebRtcVideoFrameAdapter::native_handle() const {
51 return frame_
->HasTextures() ? frame_
.get() : nullptr;
54 rtc::scoped_refptr
<webrtc::VideoFrameBuffer
>
55 WebRtcVideoFrameAdapter::NativeToI420Buffer() {
60 } // namespace content