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

Unified Diff: media/filters/decrypting_video_decoder.h

Issue 10969028: Add video decoding methods in Decryptor and add DecryptingVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move DVD to filters/ and rebase. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/decrypting_video_decoder.h
diff --git a/media/filters/decrypting_video_decoder.h b/media/filters/decrypting_video_decoder.h
new file mode 100644
index 0000000000000000000000000000000000000000..5d85731050749427b2594a7e5b298c5a1ef6ed80
--- /dev/null
+++ b/media/filters/decrypting_video_decoder.h
@@ -0,0 +1,110 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_
+#define MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "media/base/decryptor.h"
+#include "media/base/demuxer_stream.h"
+#include "media/base/video_decoder.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace media {
+
+class DecoderBuffer;
+class Decryptor;
+
+// Decryptor-based VideoDecoder implementation that can decrypt and decode
+// encrypted video buffers and return decrypted and decompressed video frames.
+//
+// TODO(xhwang): For now, DecryptingVideoDecoder relies on the decryptor to do
+// both decryption and video decoding. Add the path to use the decryptor for
+// decryption only and use other VideoDecoder implementations within
+// DecryptingVideoDecoder for video decoding.
+class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder {
+ public:
+ typedef base::Callback<
+ scoped_refptr<base::MessageLoopProxy>()> MessageLoopFactoryCB;
+ DecryptingVideoDecoder(const MessageLoopFactoryCB& message_loop_factory_cb,
ddorwin 2012/09/28 17:36:40 // Blah. // |decryptor| must to outlive this insta
xhwang 2012/09/30 19:58:51 Done.
+ Decryptor* decryptor);
+
+ // VideoDecoder implementation.
+ virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
+ const PipelineStatusCB& status_cb,
+ const StatisticsCB& statistics_cb) OVERRIDE;
+ virtual void Read(const ReadCB& read_cb) OVERRIDE;
+ virtual void Reset(const base::Closure& closure) OVERRIDE;
+ virtual void Stop(const base::Closure& closure) OVERRIDE;
+
+ protected:
+ virtual ~DecryptingVideoDecoder();
+
+ private:
+ enum DecoderState {
+ kUninitialized,
+ kNormal,
+ kDecodeFinished
+ };
+
+ // Callback for Decryptor::InitializeVideoDecoder().
+ void OnDecoderInitialized(bool success);
+
+ // Carries out the buffer reading operation scheduled by Read().
+ void DoRead(const ReadCB& read_cb);
+
+ void ReadFromDemuxerStream();
+
+ // Callback for DemuxerStream::Read().
+ void DecryptAndDecodeBuffer(DemuxerStream::Status status,
+ const scoped_refptr<DecoderBuffer>& buffer);
+
+ // Carries out the buffer decrypting/decoding operation scheduled by
+ // DecryptAndDecodeBuffer().
+ void DoDecryptAndDecodeBuffer(DemuxerStream::Status status,
+ const scoped_refptr<DecoderBuffer>& buffer);
+
+ // Callback for Decryptor::DecryptAndDecodeVideo().
+ void DeliverFrame(int buffer_size,
ddorwin 2012/09/28 17:36:40 The previous Decryptor callback started with "On".
xhwang 2012/09/30 19:58:51 We use both in media code. I use On* for callbacks
+ Decryptor::Status status,
+ const scoped_refptr<VideoFrame>& frame);
+
+ // Carries out the frame delivery operation scheduled by DeliverFrame().
+ void DoDeliverFrame(int buffer_size,
+ Decryptor::Status status,
+ const scoped_refptr<VideoFrame>& frame);
+
+ // Reset decoder and call |reset_cb_|.
+ void DoReset();
+
+ // Free decoder resources and call |stop_cb_|.
+ void DoStop();
+
+ // This is !is_null() iff Initialize() hasn't been called.
+ MessageLoopFactoryCB message_loop_factory_cb_;
+
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
+ DecoderState state_;
+ PipelineStatusCB status_cb_;
+ StatisticsCB statistics_cb_;
+ ReadCB read_cb_;
+ base::Closure reset_cb_;
+ base::Closure stop_cb_;
+
+ // Pointer to the demuxer stream that will feed us compressed buffers.
+ scoped_refptr<DemuxerStream> demuxer_stream_;
+
+ // Pointer to a Decryptor that can decrypt and decode encrypted video buffers.
ddorwin 2012/09/28 17:36:40 This comment will need to be updated when you addr
xhwang 2012/09/30 19:58:51 Removed.
+ Decryptor* const decryptor_;
+
+ DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_

Powered by Google App Engine
This is Rietveld 408576698