netwerk/protocol/device/CameraStreamImpl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/device/CameraStreamImpl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef __CAMERASTREAMIMPL_H__
     1.9 +#define __CAMERASTREAMIMPL_H__
    1.10 +
    1.11 +#include "nsString.h"
    1.12 +#include "AndroidBridge.h"
    1.13 +
    1.14 +/**
    1.15 + * This singleton class handles communication with the Android camera
    1.16 + * through JNI. It is used by the IPDL parent or directly from the chrome process
    1.17 + */
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace net {
    1.21 +    
    1.22 +class CameraStreamImpl {
    1.23 +public:
    1.24 +    class FrameCallback {
    1.25 +    public:
    1.26 +        virtual void ReceiveFrame(char* frame, uint32_t length) = 0;
    1.27 +    };
    1.28 +    
    1.29 +    /**
    1.30 +     * instance bound to a given camera
    1.31 +     */
    1.32 +    static CameraStreamImpl* GetInstance(uint32_t aCamera);
    1.33 +    
    1.34 +    bool initNeeded() {
    1.35 +        return !mInit;
    1.36 +    }
    1.37 +    
    1.38 +    FrameCallback* GetFrameCallback() {
    1.39 +        return mCallback;
    1.40 +    }
    1.41 +    
    1.42 +    bool Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* callback);
    1.43 +    void Close();
    1.44 +    
    1.45 +    uint32_t GetWidth() { return mWidth; }
    1.46 +    uint32_t GetHeight() { return mHeight; }
    1.47 +    uint32_t GetFps() { return mFps; }
    1.48 +    
    1.49 +    void takePicture(const nsAString& aFileName);
    1.50 +    
    1.51 +    void transmitFrame(JNIEnv *env, jbyteArray *data);
    1.52 +    
    1.53 +private:
    1.54 +    CameraStreamImpl(uint32_t aCamera);
    1.55 +    CameraStreamImpl(const CameraStreamImpl&);
    1.56 +    CameraStreamImpl& operator=(const CameraStreamImpl&);
    1.57 +
    1.58 +    ~CameraStreamImpl();
    1.59 +
    1.60 +    bool mInit;
    1.61 +    uint32_t mCamera;
    1.62 +    uint32_t mWidth;
    1.63 +    uint32_t mHeight;
    1.64 +    uint32_t mFps;
    1.65 +    FrameCallback* mCallback;
    1.66 +};
    1.67 +
    1.68 +} // namespace net
    1.69 +} // namespace mozilla
    1.70 +
    1.71 +#endif

mercurial