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

Side by Side Diff: media/cast/video_sender/codecs/vp8/vp8_encoder.h

Issue 138953009: Cast: Fix threading issues in VideoEncoderImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bad merge now fixed Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/test/end2end_unittest.cc ('k') | media/cast/video_sender/codecs/vp8/vp8_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_CODECS_VP8_VP8_ENCODER_H_ 5 #ifndef MEDIA_CAST_VIDEO_SENDER_CODECS_VP8_VP8_ENCODER_H_
6 #define MEDIA_CAST_VIDEO_SENDER_CODECS_VP8_VP8_ENCODER_H_ 6 #define MEDIA_CAST_VIDEO_SENDER_CODECS_VP8_VP8_ENCODER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h"
10 #include "media/cast/cast_config.h" 11 #include "media/cast/cast_config.h"
11 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" 12 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h"
12 13
13 namespace media { 14 namespace media {
14 class VideoFrame; 15 class VideoFrame;
15 } 16 }
16 17
17 // VPX forward declaration. 18 // VPX forward declaration.
18 typedef struct vpx_codec_ctx vpx_enc_ctx_t; 19 typedef struct vpx_codec_ctx vpx_enc_ctx_t;
19 20
20 namespace media { 21 namespace media {
21 namespace cast { 22 namespace cast {
22 23
23 const int kNumberOfVp8VideoBuffers = 3; 24 const int kNumberOfVp8VideoBuffers = 3;
24 25
25 class Vp8Encoder { 26 class Vp8Encoder {
26 public: 27 public:
27 Vp8Encoder(const VideoSenderConfig& video_config, 28 Vp8Encoder(const VideoSenderConfig& video_config,
28 uint8 max_unacked_frames); 29 uint8 max_unacked_frames);
29 30
30 ~Vp8Encoder(); 31 ~Vp8Encoder();
31 32
33 // Initialize the encoder before Encode() can be called. This method
34 // must be called on the thread that Encode() is called.
35 void Initialize();
36
32 // Encode a raw image (as a part of a video stream). 37 // Encode a raw image (as a part of a video stream).
33 bool Encode(const scoped_refptr<media::VideoFrame>& video_frame, 38 bool Encode(const scoped_refptr<media::VideoFrame>& video_frame,
34 transport::EncodedVideoFrame* encoded_image); 39 transport::EncodedVideoFrame* encoded_image);
35 40
36 // Update the encoder with a new target bit rate. 41 // Update the encoder with a new target bit rate.
37 void UpdateRates(uint32 new_bitrate); 42 void UpdateRates(uint32 new_bitrate);
38 43
39 // Set the next frame to be a key frame. 44 // Set the next frame to be a key frame.
40 void GenerateKeyFrame(); 45 void GenerateKeyFrame();
41 46
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scoped_ptr<vpx_enc_ctx_t> encoder_; 81 scoped_ptr<vpx_enc_ctx_t> encoder_;
77 vpx_image_t* raw_image_; 82 vpx_image_t* raw_image_;
78 83
79 bool key_frame_requested_; 84 bool key_frame_requested_;
80 int64 timestamp_; 85 int64 timestamp_;
81 uint32 last_encoded_frame_id_; 86 uint32 last_encoded_frame_id_;
82 uint32 used_buffers_frame_id_[kNumberOfVp8VideoBuffers]; 87 uint32 used_buffers_frame_id_[kNumberOfVp8VideoBuffers];
83 bool acked_frame_buffers_[kNumberOfVp8VideoBuffers]; 88 bool acked_frame_buffers_[kNumberOfVp8VideoBuffers];
84 Vp8Buffers last_used_vp8_buffer_; 89 Vp8Buffers last_used_vp8_buffer_;
85 int number_of_repeated_buffers_; 90 int number_of_repeated_buffers_;
91
92 // This is bound to the thread where Initialize() is called.
93 base::ThreadChecker thread_checker_;
86 }; 94 };
87 95
88 } // namespace cast 96 } // namespace cast
89 } // namespace media 97 } // namespace media
90 98
91 #endif // MEDIA_CAST_VIDEO_SENDER_CODECS_VP8_VP8_ENCODER_H_ 99 #endif // MEDIA_CAST_VIDEO_SENDER_CODECS_VP8_VP8_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/test/end2end_unittest.cc ('k') | media/cast/video_sender/codecs/vp8/vp8_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698