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

Unified Diff: media/cast/video_sender/external_video_encoder.h

Issue 116623002: Cast: Adding support for GPU accelerated encode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed merge nits 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/video_sender/external_video_encoder.h
diff --git a/media/cast/video_sender/video_encoder.h b/media/cast/video_sender/external_video_encoder.h
similarity index 54%
copy from media/cast/video_sender/video_encoder.h
copy to media/cast/video_sender/external_video_encoder.h
index 559dff16734fd4c9e72f1c2b8aa1a52d0e90ce73..f66d4da291d554f27cb3508ca829895e3e8c3d37 100644
--- a/media/cast/video_sender/video_encoder.h
+++ b/media/cast/video_sender/external_video_encoder.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
-#define MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
+#ifndef MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
+#define MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "media/cast/cast_config.h"
#include "media/cast/cast_environment.h"
-#include "media/cast/video_sender/codecs/vp8/vp8_encoder.h"
+#include "media/cast/video_sender/video_encoder.h"
+#include "media/filters/gpu_video_accelerator_factories.h"
namespace media {
class VideoFrame;
@@ -19,18 +19,18 @@ class VideoFrame;
namespace media {
namespace cast {
+class LocalVideoEncodeAcceleratorClient;
+
// This object is called external from the main cast thread and internally from
// the video encoder thread.
-class VideoEncoder : public VideoEncoderController {
+class ExternalVideoEncoder : public VideoEncoder {
public:
- typedef base::Callback<void(scoped_ptr<EncodedVideoFrame>,
- const base::TimeTicks&)> FrameEncodedCallback;
-
- VideoEncoder(scoped_refptr<CastEnvironment> cast_environment,
- const VideoSenderConfig& video_config,
- uint8 max_unacked_frames);
+ ExternalVideoEncoder(
+ scoped_refptr<CastEnvironment> cast_environment,
+ const VideoSenderConfig& video_config,
+ scoped_refptr<GpuVideoAcceleratorFactories> gpu_factories);
- virtual ~VideoEncoder();
+ virtual ~ExternalVideoEncoder();
// Called from the main cast thread. This function post the encode task to the
// video encoder thread;
@@ -39,23 +39,10 @@ class VideoEncoder : public VideoEncoderController {
// the encoder is done with the frame; it does not mean that the encoded frame
// has been sent out.
// Once the encoded frame is ready the frame_encoded_callback is called.
- bool EncodeVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
- const base::TimeTicks& capture_time,
- const FrameEncodedCallback& frame_encoded_callback);
-
- protected:
- struct CodecDynamicConfig {
- bool key_frame_requested;
- uint32 latest_frame_id_to_reference;
- int bit_rate;
- };
-
- // The actual encode, called from the video encoder thread.
- void EncodeVideoFrameEncoderThread(
+ virtual bool EncodeVideoFrame(
const scoped_refptr<media::VideoFrame>& video_frame,
const base::TimeTicks& capture_time,
- const CodecDynamicConfig& dynamic_config,
- const FrameEncodedCallback& frame_encoded_callback);
+ const FrameEncodedCallback& frame_encoded_callback) OVERRIDE;
// The following functions are called from the main cast thread.
virtual void SetBitRate(int new_bit_rate) OVERRIDE;
@@ -64,20 +51,32 @@ class VideoEncoder : public VideoEncoderController {
virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE;
virtual int NumberOfSkippedFrames() const OVERRIDE;
+ protected:
+ void EncoderInitialized();
+ void EncoderError();
+
private:
- friend class base::RefCountedThreadSafe<VideoEncoder>;
+ friend class LocalVideoEncodeAcceleratorClient;
const VideoSenderConfig video_config_;
scoped_refptr<CastEnvironment> cast_environment_;
- scoped_ptr<Vp8Encoder> vp8_encoder_;
- CodecDynamicConfig dynamic_config_;
+
+ bool encoder_active_;
+ bool key_frame_requested_;
bool skip_next_frame_;
int skip_count_;
- DISALLOW_COPY_AND_ASSIGN(VideoEncoder);
+ scoped_refptr<LocalVideoEncodeAcceleratorClient> video_accelerator_client_;
+ scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner_;
+
+ // Weak pointer factory for posting back LocalVideoEncodeAcceleratorClient
+ // notifications to ExternalVideoEncoder.
+ base::WeakPtrFactory<ExternalVideoEncoder> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoder);
};
} // namespace cast
} // namespace media
-#endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_
+#endif // MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
« no previous file with comments | « media/cast/video_sender/codecs/vp8/vp8_encoder.cc ('k') | media/cast/video_sender/external_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698