recordable_encoded_frame.h (2174B)
1 /* 2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef API_VIDEO_RECORDABLE_ENCODED_FRAME_H_ 12 #define API_VIDEO_RECORDABLE_ENCODED_FRAME_H_ 13 14 #include <optional> 15 16 #include "api/scoped_refptr.h" 17 #include "api/units/timestamp.h" 18 #include "api/video/color_space.h" 19 #include "api/video/encoded_image.h" 20 #include "api/video/video_codec_type.h" 21 #include "api/video/video_rotation.h" 22 23 namespace webrtc { 24 25 // Interface for accessing recordable elements of an encoded frame. 26 class RecordableEncodedFrame { 27 public: 28 // Encoded resolution in pixels 29 // TODO(bugs.webrtc.org/12114) : remove in favor of Resolution. 30 struct EncodedResolution { 31 bool empty() const { return width == 0 && height == 0; } 32 33 unsigned width = 0; 34 unsigned height = 0; 35 }; 36 37 virtual ~RecordableEncodedFrame() = default; 38 39 // Provides access to encoded data 40 virtual scoped_refptr<const EncodedImageBufferInterface> encoded_buffer() 41 const = 0; 42 43 // Optionally returns the colorspace of the encoded frame. This can differ 44 // from the eventually decoded frame's colorspace. 45 virtual std::optional<ColorSpace> color_space() const = 0; 46 47 // Optionally returns the rotation of the encoded frame. This is limited to 48 // {0,90,180,270} degrees. 49 virtual std::optional<VideoRotation> video_rotation() const = 0; 50 51 // Returns the codec of the encoded frame 52 virtual VideoCodecType codec() const = 0; 53 54 // Returns whether the encoded frame is a key frame 55 virtual bool is_key_frame() const = 0; 56 57 // Returns the frame's encoded resolution. May be 0x0 if the frame 58 // doesn't contain resolution information 59 virtual EncodedResolution resolution() const = 0; 60 61 // Returns the computed render time 62 virtual Timestamp render_time() const = 0; 63 }; 64 65 } // namespace webrtc 66 67 #endif // API_VIDEO_RECORDABLE_ENCODED_FRAME_H_