Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: media/cast/sender/size_adaptable_video_encoder_base.h

Issue 2113783002: Refactoring: Merge VideoSenderConfig and AudioSenderConfig. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mek's comment. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_ 5 #ifndef MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_
6 #define MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_ 6 #define MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 12 matching lines...) Expand all
23 23
24 // Creates and owns a VideoEncoder instance. The owned instance is an 24 // Creates and owns a VideoEncoder instance. The owned instance is an
25 // implementation that does not support changing frame sizes, and so 25 // implementation that does not support changing frame sizes, and so
26 // SizeAdaptableVideoEncoderBase acts as a proxy to automatically detect when 26 // SizeAdaptableVideoEncoderBase acts as a proxy to automatically detect when
27 // the owned instance should be replaced with one that can handle the new frame 27 // the owned instance should be replaced with one that can handle the new frame
28 // size. 28 // size.
29 class SizeAdaptableVideoEncoderBase : public VideoEncoder { 29 class SizeAdaptableVideoEncoderBase : public VideoEncoder {
30 public: 30 public:
31 SizeAdaptableVideoEncoderBase( 31 SizeAdaptableVideoEncoderBase(
32 const scoped_refptr<CastEnvironment>& cast_environment, 32 const scoped_refptr<CastEnvironment>& cast_environment,
33 const VideoSenderConfig& video_config, 33 const FrameSenderConfig& video_config,
34 const StatusChangeCallback& status_change_cb); 34 const StatusChangeCallback& status_change_cb);
35 35
36 ~SizeAdaptableVideoEncoderBase() override; 36 ~SizeAdaptableVideoEncoderBase() override;
37 37
38 // VideoEncoder implementation. 38 // VideoEncoder implementation.
39 bool EncodeVideoFrame( 39 bool EncodeVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame, 40 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& reference_time, 41 const base::TimeTicks& reference_time,
42 const FrameEncodedCallback& frame_encoded_callback) final; 42 const FrameEncodedCallback& frame_encoded_callback) final;
43 void SetBitRate(int new_bit_rate) final; 43 void SetBitRate(int new_bit_rate) final;
44 void GenerateKeyFrame() final; 44 void GenerateKeyFrame() final;
45 std::unique_ptr<VideoFrameFactory> CreateVideoFrameFactory() final; 45 std::unique_ptr<VideoFrameFactory> CreateVideoFrameFactory() final;
46 void EmitFrames() final; 46 void EmitFrames() final;
47 47
48 protected: 48 protected:
49 // Accessors for subclasses. 49 // Accessors for subclasses.
50 CastEnvironment* cast_environment() const { 50 CastEnvironment* cast_environment() const {
51 return cast_environment_.get(); 51 return cast_environment_.get();
52 } 52 }
53 const VideoSenderConfig& video_config() const { 53 const FrameSenderConfig& video_config() const { return video_config_; }
54 return video_config_;
55 }
56 const gfx::Size& frame_size() const { 54 const gfx::Size& frame_size() const {
57 return frame_size_; 55 return frame_size_;
58 } 56 }
59 FrameId next_frame_id() const { return next_frame_id_; } 57 FrameId next_frame_id() const { return next_frame_id_; }
60 58
61 // Returns a callback that calls OnEncoderStatusChange(). The callback is 59 // Returns a callback that calls OnEncoderStatusChange(). The callback is
62 // canceled by invalidating its bound weak pointer just before a replacement 60 // canceled by invalidating its bound weak pointer just before a replacement
63 // encoder is instantiated. In this scheme, OnEncoderStatusChange() can only 61 // encoder is instantiated. In this scheme, OnEncoderStatusChange() can only
64 // be called by the most-recent encoder. 62 // be called by the most-recent encoder.
65 StatusChangeCallback CreateEncoderStatusChangeCallback(); 63 StatusChangeCallback CreateEncoderStatusChangeCallback();
(...skipping 20 matching lines...) Expand all
86 void OnEncoderStatusChange(OperationalStatus status); 84 void OnEncoderStatusChange(OperationalStatus status);
87 85
88 // Called by the |encoder_| with the next EncodedFrame. 86 // Called by the |encoder_| with the next EncodedFrame.
89 void OnEncodedVideoFrame(const FrameEncodedCallback& frame_encoded_callback, 87 void OnEncodedVideoFrame(const FrameEncodedCallback& frame_encoded_callback,
90 std::unique_ptr<SenderEncodedFrame> encoded_frame); 88 std::unique_ptr<SenderEncodedFrame> encoded_frame);
91 89
92 const scoped_refptr<CastEnvironment> cast_environment_; 90 const scoped_refptr<CastEnvironment> cast_environment_;
93 91
94 // This is not const since |video_config_.starting_bitrate| is modified by 92 // This is not const since |video_config_.starting_bitrate| is modified by
95 // SetBitRate(), for when a replacement encoder is spawned. 93 // SetBitRate(), for when a replacement encoder is spawned.
96 VideoSenderConfig video_config_; 94 FrameSenderConfig video_config_;
97 95
98 // Run whenever the underlying encoder reports a status change. 96 // Run whenever the underlying encoder reports a status change.
99 const StatusChangeCallback status_change_cb_; 97 const StatusChangeCallback status_change_cb_;
100 98
101 // The underlying platform video encoder and the frame size it expects. 99 // The underlying platform video encoder and the frame size it expects.
102 std::unique_ptr<VideoEncoder> encoder_; 100 std::unique_ptr<VideoEncoder> encoder_;
103 gfx::Size frame_size_; 101 gfx::Size frame_size_;
104 102
105 // The number of frames in |encoder_|'s pipeline. If this is set to 103 // The number of frames in |encoder_|'s pipeline. If this is set to
106 // kEncoderIsInitializing, |encoder_| is not yet ready to accept frames. 104 // kEncoderIsInitializing, |encoder_| is not yet ready to accept frames.
107 enum { kEncoderIsInitializing = -1 }; 105 enum { kEncoderIsInitializing = -1 };
108 int frames_in_encoder_; 106 int frames_in_encoder_;
109 107
110 // The ID for the next frame to be emitted. 108 // The ID for the next frame to be emitted.
111 FrameId next_frame_id_; 109 FrameId next_frame_id_;
112 110
113 // NOTE: Weak pointers must be invalidated before all other member variables. 111 // NOTE: Weak pointers must be invalidated before all other member variables.
114 base::WeakPtrFactory<SizeAdaptableVideoEncoderBase> weak_factory_; 112 base::WeakPtrFactory<SizeAdaptableVideoEncoderBase> weak_factory_;
115 113
116 DISALLOW_COPY_AND_ASSIGN(SizeAdaptableVideoEncoderBase); 114 DISALLOW_COPY_AND_ASSIGN(SizeAdaptableVideoEncoderBase);
117 }; 115 };
118 116
119 } // namespace cast 117 } // namespace cast
120 } // namespace media 118 } // namespace media
121 119
122 #endif // MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_ 120 #endif // MEDIA_CAST_SENDER_SIZE_ADAPTABLE_VIDEO_ENCODER_BASE_H_
OLDNEW
« no previous file with comments | « media/cast/sender/h264_vt_encoder.cc ('k') | media/cast/sender/size_adaptable_video_encoder_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698