Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / renderer / media / webrtc / webrtc_video_frame_adapter.cc
blob9ff6f6d2840968a47c380e283057cc1b4d841c8c
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 uint8_t* WebRtcVideoFrameAdapter::data(webrtc::PlaneType type) {
47 NOTREACHED();
48 return nullptr;
51 int WebRtcVideoFrameAdapter::stride(webrtc::PlaneType type) const {
52 return frame_->stride(WebRtcToMediaPlaneType(type));
55 void* WebRtcVideoFrameAdapter::native_handle() const {
56 return frame_->HasTextures() ? frame_.get() : nullptr;
59 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
60 WebRtcVideoFrameAdapter::NativeToI420Buffer() {
61 NOTREACHED();
62 return nullptr;
65 } // namespace content