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 __CAMERASTREAMIMPL_H__ michael@0: #define __CAMERASTREAMIMPL_H__ michael@0: michael@0: #include "nsString.h" michael@0: #include "AndroidBridge.h" michael@0: michael@0: /** michael@0: * This singleton class handles communication with the Android camera michael@0: * through JNI. It is used by the IPDL parent or directly from the chrome process michael@0: */ michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class CameraStreamImpl { michael@0: public: michael@0: class FrameCallback { michael@0: public: michael@0: virtual void ReceiveFrame(char* frame, uint32_t length) = 0; michael@0: }; michael@0: michael@0: /** michael@0: * instance bound to a given camera michael@0: */ michael@0: static CameraStreamImpl* GetInstance(uint32_t aCamera); michael@0: michael@0: bool initNeeded() { michael@0: return !mInit; michael@0: } michael@0: michael@0: FrameCallback* GetFrameCallback() { michael@0: return mCallback; michael@0: } michael@0: michael@0: bool Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* callback); michael@0: void Close(); michael@0: michael@0: uint32_t GetWidth() { return mWidth; } michael@0: uint32_t GetHeight() { return mHeight; } michael@0: uint32_t GetFps() { return mFps; } michael@0: michael@0: void takePicture(const nsAString& aFileName); michael@0: michael@0: void transmitFrame(JNIEnv *env, jbyteArray *data); michael@0: michael@0: private: michael@0: CameraStreamImpl(uint32_t aCamera); michael@0: CameraStreamImpl(const CameraStreamImpl&); michael@0: CameraStreamImpl& operator=(const CameraStreamImpl&); michael@0: michael@0: ~CameraStreamImpl(); michael@0: michael@0: bool mInit; michael@0: uint32_t mCamera; michael@0: uint32_t mWidth; michael@0: uint32_t mHeight; michael@0: uint32_t mFps; michael@0: FrameCallback* mCallback; michael@0: }; michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: michael@0: #endif