michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef AndroidDeviceCaptureProvide_h_ michael@0: #define AndroidDeviceCaptureProvide_h_ michael@0: michael@0: #include "nsDeviceCaptureProvider.h" michael@0: #include "nsIAsyncInputStream.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/net/CameraStreamImpl.h" michael@0: #include "nsIEventTarget.h" michael@0: #include "nsDeque.h" michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: michael@0: class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider { michael@0: public: michael@0: AndroidCaptureProvider(); michael@0: ~AndroidCaptureProvider(); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: michael@0: nsresult Init(nsACString& aContentType, nsCaptureParams* aParams, nsIInputStream** aStream); michael@0: static AndroidCaptureProvider* sInstance; michael@0: }; michael@0: michael@0: class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback { michael@0: public: michael@0: AndroidCameraInputStream(); michael@0: ~AndroidCameraInputStream(); michael@0: michael@0: NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIINPUTSTREAM michael@0: NS_DECL_NSIASYNCINPUTSTREAM michael@0: michael@0: void ReceiveFrame(char* frame, uint32_t length); michael@0: michael@0: protected: michael@0: void NotifyListeners(); michael@0: void doClose(); michael@0: michael@0: uint32_t mAvailable; michael@0: nsCString mContentType; michael@0: uint32_t mWidth; michael@0: uint32_t mHeight; michael@0: uint32_t mCamera; michael@0: bool mHeaderSent; michael@0: bool mClosed; michael@0: nsDeque *mFrameQueue; michael@0: uint32_t mFrameSize; michael@0: mozilla::ReentrantMonitor mMonitor; michael@0: michael@0: nsCOMPtr mCallback; michael@0: nsCOMPtr mCallbackTarget; michael@0: }; michael@0: michael@0: already_AddRefed GetAndroidCaptureProvider(); michael@0: michael@0: #endif