netwerk/protocol/device/CameraStreamImpl.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef __CAMERASTREAMIMPL_H__
michael@0 6 #define __CAMERASTREAMIMPL_H__
michael@0 7
michael@0 8 #include "nsString.h"
michael@0 9 #include "AndroidBridge.h"
michael@0 10
michael@0 11 /**
michael@0 12 * This singleton class handles communication with the Android camera
michael@0 13 * through JNI. It is used by the IPDL parent or directly from the chrome process
michael@0 14 */
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace net {
michael@0 18
michael@0 19 class CameraStreamImpl {
michael@0 20 public:
michael@0 21 class FrameCallback {
michael@0 22 public:
michael@0 23 virtual void ReceiveFrame(char* frame, uint32_t length) = 0;
michael@0 24 };
michael@0 25
michael@0 26 /**
michael@0 27 * instance bound to a given camera
michael@0 28 */
michael@0 29 static CameraStreamImpl* GetInstance(uint32_t aCamera);
michael@0 30
michael@0 31 bool initNeeded() {
michael@0 32 return !mInit;
michael@0 33 }
michael@0 34
michael@0 35 FrameCallback* GetFrameCallback() {
michael@0 36 return mCallback;
michael@0 37 }
michael@0 38
michael@0 39 bool Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* callback);
michael@0 40 void Close();
michael@0 41
michael@0 42 uint32_t GetWidth() { return mWidth; }
michael@0 43 uint32_t GetHeight() { return mHeight; }
michael@0 44 uint32_t GetFps() { return mFps; }
michael@0 45
michael@0 46 void takePicture(const nsAString& aFileName);
michael@0 47
michael@0 48 void transmitFrame(JNIEnv *env, jbyteArray *data);
michael@0 49
michael@0 50 private:
michael@0 51 CameraStreamImpl(uint32_t aCamera);
michael@0 52 CameraStreamImpl(const CameraStreamImpl&);
michael@0 53 CameraStreamImpl& operator=(const CameraStreamImpl&);
michael@0 54
michael@0 55 ~CameraStreamImpl();
michael@0 56
michael@0 57 bool mInit;
michael@0 58 uint32_t mCamera;
michael@0 59 uint32_t mWidth;
michael@0 60 uint32_t mHeight;
michael@0 61 uint32_t mFps;
michael@0 62 FrameCallback* mCallback;
michael@0 63 };
michael@0 64
michael@0 65 } // namespace net
michael@0 66 } // namespace mozilla
michael@0 67
michael@0 68 #endif

mercurial