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 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_FRAME_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_FRAME_ADAPTER_H_
8 #include "media/base/video_frame.h"
9 #include "third_party/webrtc/common_video/interface/video_frame_buffer.h"
12 // Thin adapter from media::VideoFrame to webrtc::VideoFrameBuffer. This
13 // implementation is read-only and will return null if trying to get a
14 // non-const pointer to the pixel data. This object will be accessed from
15 // different threads, but that's safe since it's read-only.
16 class WebRtcVideoFrameAdapter
: public webrtc::VideoFrameBuffer
{
18 explicit WebRtcVideoFrameAdapter(
19 const scoped_refptr
<media::VideoFrame
>& frame
);
22 int width() const override
;
23 int height() const override
;
25 const uint8_t* data(webrtc::PlaneType type
) const override
;
27 uint8_t* data(webrtc::PlaneType type
) override
;
29 int stride(webrtc::PlaneType type
) const override
;
31 void* native_handle() const override
;
33 rtc::scoped_refptr
<VideoFrameBuffer
> NativeToI420Buffer() override
;
35 friend class rtc::RefCountedObject
<WebRtcVideoFrameAdapter
>;
38 ~WebRtcVideoFrameAdapter() override
;
40 scoped_refptr
<media::VideoFrame
> frame_
;
43 } // namespace content
45 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_FRAME_ADAPTER_H_