netwerk/protocol/device/CameraStreamImpl.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:23cebe45a2f7
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/. */
4
5 #ifndef __CAMERASTREAMIMPL_H__
6 #define __CAMERASTREAMIMPL_H__
7
8 #include "nsString.h"
9 #include "AndroidBridge.h"
10
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 */
15
16 namespace mozilla {
17 namespace net {
18
19 class CameraStreamImpl {
20 public:
21 class FrameCallback {
22 public:
23 virtual void ReceiveFrame(char* frame, uint32_t length) = 0;
24 };
25
26 /**
27 * instance bound to a given camera
28 */
29 static CameraStreamImpl* GetInstance(uint32_t aCamera);
30
31 bool initNeeded() {
32 return !mInit;
33 }
34
35 FrameCallback* GetFrameCallback() {
36 return mCallback;
37 }
38
39 bool Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* callback);
40 void Close();
41
42 uint32_t GetWidth() { return mWidth; }
43 uint32_t GetHeight() { return mHeight; }
44 uint32_t GetFps() { return mFps; }
45
46 void takePicture(const nsAString& aFileName);
47
48 void transmitFrame(JNIEnv *env, jbyteArray *data);
49
50 private:
51 CameraStreamImpl(uint32_t aCamera);
52 CameraStreamImpl(const CameraStreamImpl&);
53 CameraStreamImpl& operator=(const CameraStreamImpl&);
54
55 ~CameraStreamImpl();
56
57 bool mInit;
58 uint32_t mCamera;
59 uint32_t mWidth;
60 uint32_t mHeight;
61 uint32_t mFps;
62 FrameCallback* mCallback;
63 };
64
65 } // namespace net
66 } // namespace mozilla
67
68 #endif

mercurial