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

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

Issue 555563003: Cast: Flow hw encoder initialization error to extensions API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed comments and missing patch" Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_VIDEO_SENDER_H_ 5 #ifndef MEDIA_CAST_SENDER_VIDEO_SENDER_H_
6 #define MEDIA_CAST_SENDER_VIDEO_SENDER_H_ 6 #define MEDIA_CAST_SENDER_VIDEO_SENDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 19 matching lines...) Expand all
30 // packets, congestion control, video encoder, parsing and sending of 30 // packets, congestion control, video encoder, parsing and sending of
31 // RTCP packets. 31 // RTCP packets.
32 // Additionally it posts a bunch of delayed tasks to the main thread for various 32 // Additionally it posts a bunch of delayed tasks to the main thread for various
33 // timeouts. 33 // timeouts.
34 class VideoSender : public FrameSender, 34 class VideoSender : public FrameSender,
35 public base::NonThreadSafe, 35 public base::NonThreadSafe,
36 public base::SupportsWeakPtr<VideoSender> { 36 public base::SupportsWeakPtr<VideoSender> {
37 public: 37 public:
38 VideoSender(scoped_refptr<CastEnvironment> cast_environment, 38 VideoSender(scoped_refptr<CastEnvironment> cast_environment,
39 const VideoSenderConfig& video_config, 39 const VideoSenderConfig& video_config,
40 const CastInitializationCallback& initialization_cb,
40 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, 41 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
41 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, 42 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb,
42 CastTransportSender* const transport_sender); 43 CastTransportSender* const transport_sender);
43 44
44 virtual ~VideoSender(); 45 virtual ~VideoSender();
45 46
46 CastInitializationStatus InitializationResult() const { 47 CastInitializationStatus InitializationResult() const {
hubbe 2014/09/09 00:25:45 Do we need this anymore?
Alpha Left Google 2014/09/09 00:37:11 Removed.
47 return cast_initialization_status_; 48 return cast_initialization_status_;
48 } 49 }
49 50
50 // Note: It is not guaranteed that |video_frame| will actually be encoded and 51 // Note: It is not guaranteed that |video_frame| will actually be encoded and
51 // sent, if VideoSender detects too many frames in flight. Therefore, clients 52 // sent, if VideoSender detects too many frames in flight. Therefore, clients
52 // should be careful about the rate at which this method is called. 53 // should be careful about the rate at which this method is called.
53 // 54 //
54 // Note: It is invalid to call this method if InitializationResult() returns 55 // Note: It is invalid to call this method if InitializationResult() returns
55 // anything but STATUS_VIDEO_INITIALIZED. 56 // anything but STATUS_VIDEO_INITIALIZED.
56 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, 57 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
57 const base::TimeTicks& capture_time); 58 const base::TimeTicks& capture_time);
58 59
59 protected: 60 protected:
60 // Protected for testability. 61 // Protected for testability.
61 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); 62 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback);
62 63
63 private: 64 private:
64 // Returns true if there are too many frames in flight, or if the media 65 // Returns true if there are too many frames in flight, or if the media
65 // duration of the frames in flight would be too high by sending the next 66 // duration of the frames in flight would be too high by sending the next
66 // frame. The latter metric is determined from the given |capture_time| 67 // frame. The latter metric is determined from the given |capture_time|
67 // for the next frame to be encoded and sent. 68 // for the next frame to be encoded and sent.
68 bool ShouldDropNextFrame(base::TimeTicks capture_time) const; 69 bool ShouldDropNextFrame(base::TimeTicks capture_time) const;
69 70
70 // Called by the |video_encoder_| with the next EncodeFrame to send. 71 // Called by the |video_encoder_| with the next EncodeFrame to send.
71 void SendEncodedVideoFrame(int requested_bitrate_before_encode, 72 void SendEncodedVideoFrame(int requested_bitrate_before_encode,
72 scoped_ptr<EncodedFrame> encoded_frame); 73 scoped_ptr<EncodedFrame> encoded_frame);
74
75 // Called when the encoder is initialized or has failed to initialize.
76 void OnEncoderInitialized(
77 const CastInitializationCallback& initialization_cb,
78 CastInitializationStatus status);
79
73 // If this value is non zero then a fixed value is used for bitrate. 80 // If this value is non zero then a fixed value is used for bitrate.
74 // If external video encoder is used then bitrate will be fixed to 81 // If external video encoder is used then bitrate will be fixed to
75 // (min_bitrate + max_bitrate) / 2. 82 // (min_bitrate + max_bitrate) / 2.
76 const size_t fixed_bitrate_; 83 const size_t fixed_bitrate_;
77 84
78 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, 85 // Encodes media::VideoFrame images into EncodedFrames. Per configuration,
79 // this will point to either the internal software-based encoder or a proxy to 86 // this will point to either the internal software-based encoder or a proxy to
80 // a hardware-based encoder. 87 // a hardware-based encoder.
81 scoped_ptr<VideoEncoder> video_encoder_; 88 scoped_ptr<VideoEncoder> video_encoder_;
82 89
83 // The number of frames currently being processed in |video_encoder_|. 90 // The number of frames currently being processed in |video_encoder_|.
84 int frames_in_encoder_; 91 int frames_in_encoder_;
85 92
86 // When we get close to the max number of un-acked frames, we set lower 93 // When we get close to the max number of un-acked frames, we set lower
87 // the bitrate drastically to ensure that we catch up. Without this we 94 // the bitrate drastically to ensure that we catch up. Without this we
88 // risk getting stuck in a catch-up state forever. 95 // risk getting stuck in a catch-up state forever.
89 CongestionControl congestion_control_; 96 CongestionControl congestion_control_;
90 97
91 // NOTE: Weak pointers must be invalidated before all other member variables. 98 // NOTE: Weak pointers must be invalidated before all other member variables.
92 base::WeakPtrFactory<VideoSender> weak_factory_; 99 base::WeakPtrFactory<VideoSender> weak_factory_;
93 100
94 DISALLOW_COPY_AND_ASSIGN(VideoSender); 101 DISALLOW_COPY_AND_ASSIGN(VideoSender);
95 }; 102 };
96 103
97 } // namespace cast 104 } // namespace cast
98 } // namespace media 105 } // namespace media
99 106
100 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ 107 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698