webrtc/talk/media/base/videoframefactory.h
magjed@webrtc.org 2386d6dd92 Revert 8599 "Revert 8580 "Unify underlying frame buffer in I420VideoFrame and...""
It's possible to build Chrome on Windows with this patch now.

BUG=1128

> This is unfortunately causing build problems in Chrome on Windows.

>> Unify underlying frame buffer in I420VideoFrame and WebRtcVideoFrame
>>
>> Currently, I420VideoFrame uses three webrtc::Plane to store pixel data, and WebRtcVideoFrame uses WebRtcVideoFrame::FrameBuffer/webrtc::VideoFrame. The two subclasses WebRtcTextureVideoFrame and TextureVideoFrame use a NativeHandle to store pixel data, and there is also a class WebRtcVideoRenderFrame that wraps an I420VideoFrame.
>>
>> This CL replaces these classes with a new interface VideoFrameBuffer that provides the common functionality. This makes it possible to remove deep frame copies between cricket::VideoFrame and I420VideoFrame.
>>
>> Some additional minor changes are:
>> * Disallow creation of 0x0 texture frames.
>> * Remove the half-implemented ref count functions in I420VideoFrame.
>> * Remove the Alias functionality in WebRtcVideoFrame
>>
>> The final goal is to eliminate all frame copies, but to limit the scope of this CL, some planned changes are postponed to follow-up CL:s (see planned changes in https://webrtc-codereview.appspot.com/38879004, or https://docs.google.com/document/d/1bxoJZNmlo-Z9GnQwIaWpEG6hDlL_W-bzka8Zb_K2NbA/preview). Specifically, this CL:
>> * Keeps empty subclasses WebRtcTextureVideoFrame and TextureVideoFrame, and just delegates the construction to the superclass.
>> * Keeps the deep copies from cricket::VideoFrame to I420VideoFrame.
>>
>> BUG=1128
>> R=mflodman@webrtc.org, pbos@webrtc.org, perkj@webrtc.org, tommi@webrtc.org
>>
>> Review URL: https://webrtc-codereview.appspot.com/42469004

R=pbos@webrtc.org
TBR=mflodman, pbos, perkj, tommi

Review URL: https://webrtc-codereview.appspot.com/45489004

Cr-Commit-Position: refs/heads/master@{#8616}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8616 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-03-05 14:03:51 +00:00

79 lines
3.2 KiB
C++

/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
#define TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
#include "talk/media/base/videoframe.h"
#include "webrtc/base/scoped_ptr.h"
namespace cricket {
struct CapturedFrame;
class VideoFrame;
// Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame
// depending on the subclass of VideoFrameFactory.
class VideoFrameFactory {
public:
VideoFrameFactory() : apply_rotation_(true) {}
virtual ~VideoFrameFactory() {}
// The returned frame aliases the aliased_frame if the input color
// space allows for aliasing, otherwise a color conversion will
// occur. Returns NULL if conversion fails.
// The returned frame will be a center crop of |input_frame| with
// size |cropped_width| x |cropped_height|.
virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame,
int cropped_width,
int cropped_height) const = 0;
// The returned frame will be a center crop of |input_frame| with size
// |cropped_width| x |cropped_height|, scaled to |output_width| x
// |output_height|.
virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame,
int cropped_input_width,
int cropped_input_height,
int output_width,
int output_height) const;
void SetApplyRotation(bool enable) { apply_rotation_ = enable; }
protected:
bool apply_rotation_;
private:
// An internal frame buffer to avoid reallocations. It is mutable because it
// does not affect behaviour, only performance.
mutable rtc::scoped_ptr<VideoFrame> output_frame_;
};
} // namespace cricket
#endif // TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_