2008-07-29 23:50:14 -07:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is the Mozilla Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Chris Double <chris.double@double.co.nz>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2008-10-19 00:39:21 -07:00
|
|
|
#if !defined(nsChannelReader_h_)
|
|
|
|
#define nsChannelReader_h_
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsMediaStream.h"
|
2008-07-29 23:50:14 -07:00
|
|
|
|
|
|
|
#include "oggplay/oggplay.h"
|
|
|
|
|
2009-03-31 17:52:56 -07:00
|
|
|
class nsIURI;
|
2008-10-29 22:20:08 -07:00
|
|
|
class nsIChannel;
|
|
|
|
class nsIStreamListener;
|
2009-03-31 17:52:56 -07:00
|
|
|
class nsMediaDecoder;
|
2008-10-29 22:20:08 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
class nsChannelReader : public OggPlayReader
|
2008-07-29 23:50:14 -07:00
|
|
|
{
|
2008-10-19 00:39:21 -07:00
|
|
|
public:
|
|
|
|
nsChannelReader();
|
|
|
|
~nsChannelReader();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-29 22:20:08 -07:00
|
|
|
/**
|
2010-02-09 21:39:02 -08:00
|
|
|
* Initialize the reader with the media stream.
|
2009-09-10 18:44:21 -07:00
|
|
|
* This takes ownership of aStream.
|
2008-10-29 22:20:08 -07:00
|
|
|
*/
|
2009-09-10 18:44:21 -07:00
|
|
|
void Init(nsMediaStream* aStream);
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2009-03-31 17:52:56 -07:00
|
|
|
nsMediaStream* Stream() { return mStream; }
|
2009-01-21 15:54:40 -08:00
|
|
|
|
2009-05-18 22:25:51 -07:00
|
|
|
// Set the time of the last frame. This is returned in duration() to
|
|
|
|
// liboggplay. Call with decoder lock obtained so that liboggplay cannot
|
|
|
|
// call duration() on the decoder thread while it is changing.
|
|
|
|
void SetLastFrameTime(PRInt64 aTime);
|
2009-03-03 02:23:54 -08:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
nsIPrincipal* GetCurrentPrincipal();
|
|
|
|
|
|
|
|
// Implementation of OggPlay Reader API.
|
2008-07-29 23:50:14 -07:00
|
|
|
OggPlayErrorCode initialise(int aBlock);
|
|
|
|
OggPlayErrorCode destroy();
|
|
|
|
size_t io_read(char* aBuffer, size_t aCount);
|
|
|
|
int io_seek(long aOffset, int aWhence);
|
2009-03-29 18:19:10 -07:00
|
|
|
long io_tell();
|
2009-03-03 02:23:54 -08:00
|
|
|
ogg_int64_t duration();
|
2008-10-19 00:39:21 -07:00
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
public:
|
2009-03-29 18:19:10 -07:00
|
|
|
nsAutoPtr<nsMediaStream> mStream;
|
2009-03-03 02:23:54 -08:00
|
|
|
|
2009-05-18 22:25:51 -07:00
|
|
|
// Timestamp of the end of the last frame in the media resource.
|
|
|
|
// -1 if not known.
|
|
|
|
PRInt64 mLastFrameTime;
|
2008-07-29 23:50:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|