|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef AndroidDeviceCaptureProvide_h_ |
|
7 #define AndroidDeviceCaptureProvide_h_ |
|
8 |
|
9 #include "nsDeviceCaptureProvider.h" |
|
10 #include "nsIAsyncInputStream.h" |
|
11 #include "nsCOMPtr.h" |
|
12 #include "nsAutoPtr.h" |
|
13 #include "nsString.h" |
|
14 #include "mozilla/net/CameraStreamImpl.h" |
|
15 #include "nsIEventTarget.h" |
|
16 #include "nsDeque.h" |
|
17 #include "mozilla/ReentrantMonitor.h" |
|
18 |
|
19 class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider { |
|
20 public: |
|
21 AndroidCaptureProvider(); |
|
22 ~AndroidCaptureProvider(); |
|
23 |
|
24 NS_DECL_THREADSAFE_ISUPPORTS |
|
25 |
|
26 nsresult Init(nsACString& aContentType, nsCaptureParams* aParams, nsIInputStream** aStream); |
|
27 static AndroidCaptureProvider* sInstance; |
|
28 }; |
|
29 |
|
30 class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback { |
|
31 public: |
|
32 AndroidCameraInputStream(); |
|
33 ~AndroidCameraInputStream(); |
|
34 |
|
35 NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams); |
|
36 |
|
37 NS_DECL_THREADSAFE_ISUPPORTS |
|
38 NS_DECL_NSIINPUTSTREAM |
|
39 NS_DECL_NSIASYNCINPUTSTREAM |
|
40 |
|
41 void ReceiveFrame(char* frame, uint32_t length); |
|
42 |
|
43 protected: |
|
44 void NotifyListeners(); |
|
45 void doClose(); |
|
46 |
|
47 uint32_t mAvailable; |
|
48 nsCString mContentType; |
|
49 uint32_t mWidth; |
|
50 uint32_t mHeight; |
|
51 uint32_t mCamera; |
|
52 bool mHeaderSent; |
|
53 bool mClosed; |
|
54 nsDeque *mFrameQueue; |
|
55 uint32_t mFrameSize; |
|
56 mozilla::ReentrantMonitor mMonitor; |
|
57 |
|
58 nsCOMPtr<nsIInputStreamCallback> mCallback; |
|
59 nsCOMPtr<nsIEventTarget> mCallbackTarget; |
|
60 }; |
|
61 |
|
62 already_AddRefed<AndroidCaptureProvider> GetAndroidCaptureProvider(); |
|
63 |
|
64 #endif |