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