netwerk/protocol/device/AndroidCaptureProvider.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/device/AndroidCaptureProvider.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef AndroidDeviceCaptureProvide_h_
    1.10 +#define AndroidDeviceCaptureProvide_h_
    1.11 +
    1.12 +#include "nsDeviceCaptureProvider.h"
    1.13 +#include "nsIAsyncInputStream.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsAutoPtr.h"
    1.16 +#include "nsString.h"
    1.17 +#include "mozilla/net/CameraStreamImpl.h"
    1.18 +#include "nsIEventTarget.h"
    1.19 +#include "nsDeque.h"
    1.20 +#include "mozilla/ReentrantMonitor.h"
    1.21 +
    1.22 +class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider {
    1.23 +  public:
    1.24 +    AndroidCaptureProvider();
    1.25 +    ~AndroidCaptureProvider();
    1.26 +
    1.27 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.28 +
    1.29 +    nsresult Init(nsACString& aContentType, nsCaptureParams* aParams, nsIInputStream** aStream);
    1.30 +    static AndroidCaptureProvider* sInstance;
    1.31 +};
    1.32 +
    1.33 +class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback {
    1.34 +  public:
    1.35 +    AndroidCameraInputStream();
    1.36 +    ~AndroidCameraInputStream();
    1.37 +
    1.38 +    NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams);
    1.39 +
    1.40 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.41 +    NS_DECL_NSIINPUTSTREAM
    1.42 +    NS_DECL_NSIASYNCINPUTSTREAM
    1.43 +
    1.44 +    void ReceiveFrame(char* frame, uint32_t length);
    1.45 +
    1.46 +  protected:
    1.47 +    void NotifyListeners();
    1.48 +    void doClose();
    1.49 +
    1.50 +    uint32_t mAvailable;
    1.51 +    nsCString mContentType;
    1.52 +    uint32_t mWidth;
    1.53 +    uint32_t mHeight;
    1.54 +    uint32_t mCamera;
    1.55 +    bool mHeaderSent;
    1.56 +    bool mClosed;
    1.57 +    nsDeque *mFrameQueue;
    1.58 +    uint32_t mFrameSize;
    1.59 +    mozilla::ReentrantMonitor mMonitor;
    1.60 +
    1.61 +    nsCOMPtr<nsIInputStreamCallback> mCallback;
    1.62 +    nsCOMPtr<nsIEventTarget> mCallbackTarget;
    1.63 +};
    1.64 +
    1.65 +already_AddRefed<AndroidCaptureProvider> GetAndroidCaptureProvider();
    1.66 +
    1.67 +#endif

mercurial