2017-01-10 07:44:26 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef API_VIDEO_VIDEO_FRAME_H_
|
|
|
|
|
#define API_VIDEO_VIDEO_FRAME_H_
|
2017-01-10 07:44:26 -08:00
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video/video_rotation.h"
|
|
|
|
|
#include "api/video/video_frame_buffer.h"
|
2017-01-10 07:44:26 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class VideoFrame {
|
|
|
|
|
public:
|
|
|
|
|
// TODO(nisse): This constructor is consistent with the now deleted
|
|
|
|
|
// cricket::WebRtcVideoFrame. We should consider whether or not we
|
|
|
|
|
// want to stick to this style and deprecate the other constructor.
|
|
|
|
|
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
|
|
|
|
webrtc::VideoRotation rotation,
|
|
|
|
|
int64_t timestamp_us);
|
|
|
|
|
|
|
|
|
|
// Preferred constructor.
|
|
|
|
|
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
|
|
|
|
uint32_t timestamp,
|
|
|
|
|
int64_t render_time_ms,
|
|
|
|
|
VideoRotation rotation);
|
|
|
|
|
|
|
|
|
|
~VideoFrame();
|
|
|
|
|
|
|
|
|
|
// Support move and copy.
|
|
|
|
|
VideoFrame(const VideoFrame&);
|
|
|
|
|
VideoFrame(VideoFrame&&);
|
|
|
|
|
VideoFrame& operator=(const VideoFrame&);
|
|
|
|
|
VideoFrame& operator=(VideoFrame&&);
|
|
|
|
|
|
|
|
|
|
// Get frame width.
|
|
|
|
|
int width() const;
|
|
|
|
|
// Get frame height.
|
|
|
|
|
int height() const;
|
Reland of Drop frames until specified bitrate is achieved. (patchset #1 id:1 of https://codereview.webrtc.org/2666303002/ )
Reason for revert:
Perf test broke as it made assumptions that quality scaling was turned off. This turns out not to be the case. Fixed by turning quality scaling off for the tests.
Original issue's description:
> Revert of Drop frames until specified bitrate is achieved. (patchset #12 id:240001 of https://codereview.webrtc.org/2630333002/ )
>
> Reason for revert:
> due to failures on perf tests (not on perf stats, but fails running due to dcheck failures), see e.g., https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20(K%20Nexus5)
>
> Original issue's description:
> > Drop frames until specified bitrate is achieved.
> >
> > This CL fixes a regression introduced with the new quality scaler
> > where the video would no longer start in a scaled mode. This CL adds
> > code that compares incoming captured frames to the target bitrate,
> > and if they are found to be too large, they are dropped and sinkWants
> > set to a lower resolution. The number of dropped frames should be low
> > (0-4 in most cases) and should not introduce a noticeable delay, or
> > at least should be preferrable to having the first 2-4 seconds of video
> > have very low quality.
> >
> > BUG=webrtc:6953
> >
> > Review-Url: https://codereview.webrtc.org/2630333002
> > Cr-Commit-Position: refs/heads/master@{#16391}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/83399caec5762d2dad038b8e9d86163e92c18c9f
>
> TBR=perkj@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,kthelgason@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6953
>
> Review-Url: https://codereview.webrtc.org/2666303002
> Cr-Commit-Position: refs/heads/master@{#16395}
> Committed: https://chromium.googlesource.com/external/webrtc/+/35fc2aa82fb5a562f3f76f2b91a55f05ebfd4874
TBR=perkj@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,minyue@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:6953
Review-Url: https://codereview.webrtc.org/2675223002
Cr-Commit-Position: refs/heads/master@{#16473}
2017-02-07 07:02:22 -08:00
|
|
|
// Get frame size in pixels.
|
|
|
|
|
uint32_t size() const;
|
2017-01-10 07:44:26 -08:00
|
|
|
|
|
|
|
|
// System monotonic clock, same timebase as rtc::TimeMicros().
|
|
|
|
|
int64_t timestamp_us() const { return timestamp_us_; }
|
|
|
|
|
void set_timestamp_us(int64_t timestamp_us) { timestamp_us_ = timestamp_us; }
|
|
|
|
|
|
|
|
|
|
// TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
|
|
|
|
|
// merge, timestamps other than timestamp_us will likely be
|
|
|
|
|
// deprecated.
|
|
|
|
|
|
|
|
|
|
// Set frame timestamp (90kHz).
|
|
|
|
|
void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }
|
|
|
|
|
|
|
|
|
|
// Get frame timestamp (90kHz).
|
|
|
|
|
uint32_t timestamp() const { return timestamp_rtp_; }
|
|
|
|
|
|
|
|
|
|
// For now, transport_frame_id and rtp timestamp are the same.
|
|
|
|
|
// TODO(nisse): Must be handled differently for QUIC.
|
|
|
|
|
uint32_t transport_frame_id() const { return timestamp(); }
|
|
|
|
|
|
|
|
|
|
// Set capture ntp time in milliseconds.
|
2017-01-30 02:43:18 -08:00
|
|
|
// TODO(nisse): Deprecated. Migrate all users to timestamp_us().
|
2017-01-10 07:44:26 -08:00
|
|
|
void set_ntp_time_ms(int64_t ntp_time_ms) { ntp_time_ms_ = ntp_time_ms; }
|
|
|
|
|
|
|
|
|
|
// Get capture ntp time in milliseconds.
|
2017-01-30 02:43:18 -08:00
|
|
|
// TODO(nisse): Deprecated. Migrate all users to timestamp_us().
|
2017-01-10 07:44:26 -08:00
|
|
|
int64_t ntp_time_ms() const { return ntp_time_ms_; }
|
|
|
|
|
|
|
|
|
|
// Naming convention for Coordination of Video Orientation. Please see
|
|
|
|
|
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
|
|
|
|
|
//
|
|
|
|
|
// "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
|
|
|
|
|
//
|
|
|
|
|
// "not pending" = a frame that has a VideoRotation == 0.
|
|
|
|
|
//
|
|
|
|
|
// "apply rotation" = modify a frame from being "pending" to being "not
|
|
|
|
|
// pending" rotation (a no-op for "unrotated").
|
|
|
|
|
//
|
|
|
|
|
VideoRotation rotation() const { return rotation_; }
|
|
|
|
|
void set_rotation(VideoRotation rotation) { rotation_ = rotation; }
|
|
|
|
|
|
|
|
|
|
// Get render time in milliseconds.
|
2017-01-30 02:43:18 -08:00
|
|
|
// TODO(nisse): Deprecated. Migrate all users to timestamp_us().
|
2017-01-10 07:44:26 -08:00
|
|
|
int64_t render_time_ms() const;
|
|
|
|
|
|
|
|
|
|
// Return the underlying buffer. Never nullptr for a properly
|
|
|
|
|
// initialized VideoFrame.
|
|
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
|
|
|
|
|
|
|
|
|
|
// TODO(nisse): Deprecated.
|
|
|
|
|
// Return true if the frame is stored in a texture.
|
|
|
|
|
bool is_texture() const {
|
2017-06-01 10:02:26 -07:00
|
|
|
return video_frame_buffer()->type() == VideoFrameBuffer::Type::kNative;
|
2017-01-10 07:44:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// An opaque reference counted handle that stores the pixel data.
|
|
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
|
|
|
|
uint32_t timestamp_rtp_;
|
|
|
|
|
int64_t ntp_time_ms_;
|
|
|
|
|
int64_t timestamp_us_;
|
|
|
|
|
VideoRotation rotation_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // API_VIDEO_VIDEO_FRAME_H_
|