From b4c830ae8bcbe9eba8362465db7bd1a64b39716a Mon Sep 17 00:00:00 2001 From: "scherkus@chromium.org" Date: Mon, 28 Jan 2013 23:35:59 +0000 Subject: Tighten up media::DecoderBuffer API contract for end of stream buffers (round 2). Folks shouldn't be calling methods on end of stream buffers since the definition is undefined. This time with unit test fixes! TBR=yzshen Review URL: https://chromiumcodereview.appspot.com/11929015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179212 0039d316-1c4b-4281-b951-d872f2087c98 --- media/base/decoder_buffer.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'media/base/decoder_buffer.h') diff --git a/media/base/decoder_buffer.h b/media/base/decoder_buffer.h index 7cb496b..c23e88f 100644 --- a/media/base/decoder_buffer.h +++ b/media/base/decoder_buffer.h @@ -5,6 +5,8 @@ #ifndef MEDIA_BASE_DECODER_BUFFER_H_ #define MEDIA_BASE_DECODER_BUFFER_H_ +#include + #include "base/memory/aligned_memory.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -23,6 +25,8 @@ class DecryptConfig; // allocated using FFmpeg with particular alignment and padding requirements. // // Also includes decoder specific functionality for decryption. +// +// NOTE: It is illegal to call any method when IsEndOfStream() is true. class MEDIA_EXPORT DecoderBuffer : public base::RefCountedThreadSafe { public: @@ -43,8 +47,10 @@ class MEDIA_EXPORT DecoderBuffer // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. static scoped_refptr CopyFrom(const uint8* data, int size); - // Create a DecoderBuffer indicating we've reached end of stream. GetData() - // and GetWritableData() will return NULL and GetDataSize() will return 0. + // Create a DecoderBuffer indicating we've reached end of stream. + // + // Calling any method other than IsEndOfStream() on the resulting buffer + // is disallowed. static scoped_refptr CreateEOSBuffer(); base::TimeDelta GetTimestamp() const; @@ -64,6 +70,9 @@ class MEDIA_EXPORT DecoderBuffer // If there's no data in this buffer, it represents end of stream. bool IsEndOfStream() const; + // Returns a human-readable string describing |*this|. + std::string AsHumanReadableString(); + protected: friend class base::RefCountedThreadSafe; -- cgit v1.1