Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / content / renderer / media / webrtc / webrtc_video_frame_adapter.cc
blob28dc533871bcf711d8db0d29d02f34e49827ac62
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"
9 namespace content {
10 namespace {
11 int WebRtcToMediaPlaneType(webrtc::PlaneType type) {
12 switch (type) {
13 case webrtc::kYPlane:
14 return media::VideoFrame::kYPlane;
15 case webrtc::kUPlane:
16 return media::VideoFrame::kUPlane;
17 case webrtc::kVPlane:
18 return media::VideoFrame::kVPlane;
19 default:
20 NOTREACHED();
21 return media::VideoFrame::kMaxPlanes;
24 } // anonymous namespace
26 WebRtcVideoFrameAdapter::WebRtcVideoFrameAdapter(
27 const scoped_refptr<media::VideoFrame>& frame)
28 : frame_(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() {
56 NOTREACHED();
57 return nullptr;
60 } // namespace content