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

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

Issue 74133002: Cast: Removed unnecessary ref counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge TOT Created 7 years 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/audio_receiver/audio_receiver.cc ('k') | media/cast/video_sender/video_encoder.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_VIDEO_SENDER_VIDEO_ENCODER_H_ 5 #ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_ 6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
7 7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "media/cast/cast_config.h" 11 #include "media/cast/cast_config.h"
12 #include "media/cast/cast_environment.h" 12 #include "media/cast/cast_environment.h"
13 #include "media/cast/video_sender/codecs/vp8/vp8_encoder.h" 13 #include "media/cast/video_sender/codecs/vp8/vp8_encoder.h"
14 14
15 namespace media { 15 namespace media {
16 class VideoFrame; 16 class VideoFrame;
17 } 17 }
18 18
19 namespace media { 19 namespace media {
20 namespace cast { 20 namespace cast {
21 21
22 // This object is called external from the main cast thread and internally from 22 // This object is called external from the main cast thread and internally from
23 // the video encoder thread. 23 // the video encoder thread.
24 class VideoEncoder : public VideoEncoderController, 24 class VideoEncoder : public VideoEncoderController {
25 public base::RefCountedThreadSafe<VideoEncoder> {
26 public: 25 public:
27 typedef base::Callback<void(scoped_ptr<EncodedVideoFrame>, 26 typedef base::Callback<void(scoped_ptr<EncodedVideoFrame>,
28 const base::TimeTicks&)> FrameEncodedCallback; 27 const base::TimeTicks&)> FrameEncodedCallback;
29 28
30 VideoEncoder(scoped_refptr<CastEnvironment> cast_environment, 29 VideoEncoder(scoped_refptr<CastEnvironment> cast_environment,
31 const VideoSenderConfig& video_config, 30 const VideoSenderConfig& video_config,
32 uint8 max_unacked_frames); 31 uint8 max_unacked_frames);
33 32
33 virtual ~VideoEncoder();
34
34 // Called from the main cast thread. This function post the encode task to the 35 // Called from the main cast thread. This function post the encode task to the
35 // video encoder thread; 36 // video encoder thread;
36 // The video_frame must be valid until the closure callback is called. 37 // The video_frame must be valid until the closure callback is called.
37 // The closure callback is called from the video encoder thread as soon as 38 // The closure callback is called from the video encoder thread as soon as
38 // the encoder is done with the frame; it does not mean that the encoded frame 39 // the encoder is done with the frame; it does not mean that the encoded frame
39 // has been sent out. 40 // has been sent out.
40 // Once the encoded frame is ready the frame_encoded_callback is called. 41 // Once the encoded frame is ready the frame_encoded_callback is called.
41 bool EncodeVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, 42 bool EncodeVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
42 const base::TimeTicks& capture_time, 43 const base::TimeTicks& capture_time,
43 const FrameEncodedCallback& frame_encoded_callback, 44 const FrameEncodedCallback& frame_encoded_callback,
44 const base::Closure frame_release_callback); 45 const base::Closure frame_release_callback);
45 46
46 protected: 47 protected:
47 virtual ~VideoEncoder();
48
49 struct CodecDynamicConfig { 48 struct CodecDynamicConfig {
50 bool key_frame_requested; 49 bool key_frame_requested;
51 uint32 latest_frame_id_to_reference; 50 uint32 latest_frame_id_to_reference;
52 int bit_rate; 51 int bit_rate;
53 }; 52 };
54 53
55 // The actual encode, called from the video encoder thread. 54 // The actual encode, called from the video encoder thread.
56 void EncodeVideoFrameEncoderThread( 55 void EncodeVideoFrameEncoderThread(
57 const scoped_refptr<media::VideoFrame>& video_frame, 56 const scoped_refptr<media::VideoFrame>& video_frame,
58 const base::TimeTicks& capture_time, 57 const base::TimeTicks& capture_time,
59 const CodecDynamicConfig& dynamic_config, 58 const CodecDynamicConfig& dynamic_config,
60 const FrameEncodedCallback& frame_encoded_callback, 59 const FrameEncodedCallback& frame_encoded_callback,
61 const base::Closure frame_release_callback); 60 const base::Closure frame_release_callback);
62 61
63 // The following functions are called from the main cast thread. 62 // The following functions are called from the main cast thread.
64 virtual void SetBitRate(int new_bit_rate) OVERRIDE; 63 virtual void SetBitRate(int new_bit_rate) OVERRIDE;
65 virtual void SkipNextFrame(bool skip_next_frame) OVERRIDE; 64 virtual void SkipNextFrame(bool skip_next_frame) OVERRIDE;
66 virtual void GenerateKeyFrame() OVERRIDE; 65 virtual void GenerateKeyFrame() OVERRIDE;
67 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE; 66 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE;
68 virtual int NumberOfSkippedFrames() const OVERRIDE; 67 virtual int NumberOfSkippedFrames() const OVERRIDE;
69 68
70 private: 69 private:
71 friend class base::RefCountedThreadSafe<VideoEncoder>;
72
73 const VideoSenderConfig video_config_; 70 const VideoSenderConfig video_config_;
74 scoped_refptr<CastEnvironment> cast_environment_; 71 scoped_refptr<CastEnvironment> cast_environment_;
75 scoped_ptr<Vp8Encoder> vp8_encoder_; 72 scoped_ptr<Vp8Encoder> vp8_encoder_;
76 CodecDynamicConfig dynamic_config_; 73 CodecDynamicConfig dynamic_config_;
77 bool skip_next_frame_; 74 bool skip_next_frame_;
78 int skip_count_; 75 int skip_count_;
79 76
80 DISALLOW_COPY_AND_ASSIGN(VideoEncoder); 77 DISALLOW_COPY_AND_ASSIGN(VideoEncoder);
81 }; 78 };
82 79
83 } // namespace cast 80 } // namespace cast
84 } // namespace media 81 } // namespace media
85 82
86 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_ 83 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/audio_receiver/audio_receiver.cc ('k') | media/cast/video_sender/video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698