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

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

Issue 688423003: [Cast] VideoFrameFactory interface to vend frames with encoder affinity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/tick_clock.h" 13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/cast/cast_config.h" 15 #include "media/cast/cast_config.h"
16 #include "media/cast/sender/congestion_control.h" 16 #include "media/cast/sender/congestion_control.h"
17 #include "media/cast/sender/frame_sender.h" 17 #include "media/cast/sender/frame_sender.h"
18 #include "media/cast/sender/video_frame_factory.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 class VideoFrame; 22 class VideoFrame;
22 23
23 namespace cast { 24 namespace cast {
24 25
25 class CastTransportSender; 26 class CastTransportSender;
26 class VideoEncoder; 27 class VideoEncoder;
27 28
(...skipping 21 matching lines...) Expand all
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& reference_time); 58 const base::TimeTicks& reference_time);
58 59
60 // Returns a |VideoFrameFactory| that can be used to create
61 // |media::VideoFrame| objects with potentially better affinity with the
62 // encoder.
63 scoped_refptr<VideoFrameFactory> video_frame_factory() {
64 return video_frame_factory_;
65 }
66
59 protected: 67 protected:
60 int GetNumberOfFramesInEncoder() const override; 68 int GetNumberOfFramesInEncoder() const override;
61 base::TimeDelta GetInFlightMediaDuration() const override; 69 base::TimeDelta GetInFlightMediaDuration() const override;
62 void OnAck(uint32 frame_id) override; 70 void OnAck(uint32 frame_id) override;
63 71
64 private: 72 private:
65 // Called when the encoder is initialized or has failed to initialize. 73 // Called when the encoder is initialized or has failed to initialize.
66 void OnEncoderInitialized( 74 void OnEncoderInitialized(
67 const CastInitializationCallback& initialization_cb, 75 const CastInitializationCallback& initialization_cb,
68 CastInitializationStatus status); 76 CastInitializationStatus status);
69 77
70 // Called by the |video_encoder_| with the next EncodedFrame to send. 78 // Called by the |video_encoder_| with the next EncodedFrame to send.
71 void OnEncodedVideoFrame(int encoder_bitrate, 79 void OnEncodedVideoFrame(int encoder_bitrate,
72 scoped_ptr<EncodedFrame> encoded_frame); 80 scoped_ptr<EncodedFrame> encoded_frame);
73 81
74 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, 82 // Encodes media::VideoFrame images into EncodedFrames. Per configuration,
75 // this will point to either the internal software-based encoder or a proxy to 83 // this will point to either the internal software-based encoder or a proxy to
76 // a hardware-based encoder. 84 // a hardware-based encoder.
77 scoped_ptr<VideoEncoder> video_encoder_; 85 scoped_ptr<VideoEncoder> video_encoder_;
78 86
87 // Provides |media::VideoFrame| objects suitable for encoding. The encoder may
88 // provide a specialized instance, otherwise a default implementation is used.
89 scoped_refptr<VideoFrameFactory> video_frame_factory_;
90
79 // The number of frames queued for encoding, but not yet sent. 91 // The number of frames queued for encoding, but not yet sent.
80 int frames_in_encoder_; 92 int frames_in_encoder_;
81 93
82 // The duration of video queued for encoding, but not yet sent. 94 // The duration of video queued for encoding, but not yet sent.
83 base::TimeDelta duration_in_encoder_; 95 base::TimeDelta duration_in_encoder_;
84 96
85 // The timestamp of the frame that was last enqueued in |video_encoder_|. 97 // The timestamp of the frame that was last enqueued in |video_encoder_|.
86 RtpTimestamp last_enqueued_frame_rtp_timestamp_; 98 RtpTimestamp last_enqueued_frame_rtp_timestamp_;
87 base::TimeTicks last_enqueued_frame_reference_time_; 99 base::TimeTicks last_enqueued_frame_reference_time_;
88 100
89 // Remember what we set the bitrate to before, no need to set it again if 101 // Remember what we set the bitrate to before, no need to set it again if
90 // we get the same value. 102 // we get the same value.
91 uint32 last_bitrate_; 103 uint32 last_bitrate_;
92 104
93 PlayoutDelayChangeCB playout_delay_change_cb_; 105 PlayoutDelayChangeCB playout_delay_change_cb_;
94 106
95 // NOTE: Weak pointers must be invalidated before all other member variables. 107 // NOTE: Weak pointers must be invalidated before all other member variables.
96 base::WeakPtrFactory<VideoSender> weak_factory_; 108 base::WeakPtrFactory<VideoSender> weak_factory_;
97 109
98 DISALLOW_COPY_AND_ASSIGN(VideoSender); 110 DISALLOW_COPY_AND_ASSIGN(VideoSender);
99 }; 111 };
100 112
101 } // namespace cast 113 } // namespace cast
102 } // namespace media 114 } // namespace media
103 115
104 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ 116 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698