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

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 compile 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
« no previous file with comments | « media/cast/sender/external_video_encoder_unittest.cc ('k') | media/cast/sender/video_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 return cast_initialization_status_;
48 }
49
50 // Note: It is not guaranteed that |video_frame| will actually be encoded and 47 // 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 48 // sent, if VideoSender detects too many frames in flight. Therefore, clients
52 // should be careful about the rate at which this method is called. 49 // should be careful about the rate at which this method is called.
53 // 50 //
54 // Note: It is invalid to call this method if InitializationResult() returns 51 // Note: It is invalid to call this method if InitializationResult() returns
55 // anything but STATUS_VIDEO_INITIALIZED. 52 // anything but STATUS_VIDEO_INITIALIZED.
56 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, 53 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
57 const base::TimeTicks& capture_time); 54 const base::TimeTicks& capture_time);
58 55
59 protected: 56 protected:
60 virtual int GetNumberOfFramesInEncoder() const OVERRIDE; 57 virtual int GetNumberOfFramesInEncoder() const OVERRIDE;
61 virtual void OnAck(uint32 frame_id) OVERRIDE; 58 virtual void OnAck(uint32 frame_id) OVERRIDE;
62 59
63 private: 60 private:
61 // Called when the encoder is initialized or has failed to initialize.
62 void OnEncoderInitialized(
63 const CastInitializationCallback& initialization_cb,
64 CastInitializationStatus status);
65
64 // Called by the |video_encoder_| with the next EncodedFrame to send. 66 // Called by the |video_encoder_| with the next EncodedFrame to send.
65 void OnEncodedVideoFrame(int encoder_bitrate, 67 void OnEncodedVideoFrame(int encoder_bitrate,
66 scoped_ptr<EncodedFrame> encoded_frame); 68 scoped_ptr<EncodedFrame> encoded_frame);
67 69
68 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, 70 // Encodes media::VideoFrame images into EncodedFrames. Per configuration,
69 // this will point to either the internal software-based encoder or a proxy to 71 // this will point to either the internal software-based encoder or a proxy to
70 // a hardware-based encoder. 72 // a hardware-based encoder.
71 scoped_ptr<VideoEncoder> video_encoder_; 73 scoped_ptr<VideoEncoder> video_encoder_;
72 74
73 // The number of frames queued for encoding, but not yet sent. 75 // The number of frames queued for encoding, but not yet sent.
74 int frames_in_encoder_; 76 int frames_in_encoder_;
75 77
76 // Remember what we set the bitrate to before, no need to set it again if 78 // Remember what we set the bitrate to before, no need to set it again if
77 // we get the same value. 79 // we get the same value.
78 uint32 last_bitrate_; 80 uint32 last_bitrate_;
79 81
80 // NOTE: Weak pointers must be invalidated before all other member variables. 82 // NOTE: Weak pointers must be invalidated before all other member variables.
81 base::WeakPtrFactory<VideoSender> weak_factory_; 83 base::WeakPtrFactory<VideoSender> weak_factory_;
82 84
83 DISALLOW_COPY_AND_ASSIGN(VideoSender); 85 DISALLOW_COPY_AND_ASSIGN(VideoSender);
84 }; 86 };
85 87
86 } // namespace cast 88 } // namespace cast
87 } // namespace media 89 } // namespace media
88 90
89 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ 91 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_
OLDNEW
« no previous file with comments | « media/cast/sender/external_video_encoder_unittest.cc ('k') | media/cast/sender/video_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698