diff options
author | Andreas Huber <andih@google.com> | 2012-08-29 11:41:50 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-08-29 15:06:57 -0700 |
commit | d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c (patch) | |
tree | 3c4c7a83313d169b13c79c9660afeb804d27b975 /media/libmediaplayerservice | |
parent | eb941f9a0c8474324732a99387cc6d8cb4ab01ef (diff) | |
download | frameworks_av-d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c.zip frameworks_av-d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c.tar.gz frameworks_av-d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c.tar.bz2 |
Initial checkin of support for acting as a wifi display source
Change-Id: I08f17efa0c7d007e17408feb7d4fbef0a19f531a
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/Android.mk | 64 | ||||
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.cpp | 23 | ||||
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.h | 3 | ||||
-rw-r--r-- | media/libmediaplayerservice/RemoteDisplay.cpp | 56 | ||||
-rw-r--r-- | media/libmediaplayerservice/RemoteDisplay.h | 54 |
5 files changed, 169 insertions, 31 deletions
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk index 1373d3c..c7227b0 100644 --- a/media/libmediaplayerservice/Android.mk +++ b/media/libmediaplayerservice/Android.mk @@ -9,45 +9,47 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ ActivityManager.cpp \ Crypto.cpp \ - MediaRecorderClient.cpp \ MediaPlayerFactory.cpp \ MediaPlayerService.cpp \ + MediaRecorderClient.cpp \ MetadataRetrieverClient.cpp \ - TestPlayerStub.cpp \ - MidiMetadataRetriever.cpp \ MidiFile.cpp \ + MidiMetadataRetriever.cpp \ + RemoteDisplay.cpp \ StagefrightPlayer.cpp \ - StagefrightRecorder.cpp - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - libbinder \ - libvorbisidec \ - libsonivox \ - libmedia \ - libmedia_native \ - libcamera_client \ - libstagefright \ - libstagefright_omx \ - libstagefright_foundation \ - libgui \ - libdl - -LOCAL_STATIC_LIBRARIES := \ - libstagefright_nuplayer \ - libstagefright_rtsp \ - -LOCAL_C_INCLUDES := \ - $(call include-path-for, graphics corecg) \ - $(TOP)/frameworks/av/media/libstagefright/include \ - $(TOP)/frameworks/av/media/libstagefright/rtsp \ - $(TOP)/frameworks/native/include/media/openmax \ - $(TOP)/external/tremolo/Tremolo \ + StagefrightRecorder.cpp \ + TestPlayerStub.cpp \ + +LOCAL_SHARED_LIBRARIES := \ + libbinder \ + libcamera_client \ + libcutils \ + libdl \ + libgui \ + libmedia \ + libmedia_native \ + libsonivox \ + libstagefright \ + libstagefright_foundation \ + libstagefright_omx \ + libstagefright_wfd \ + libutils \ + libvorbisidec \ + +LOCAL_STATIC_LIBRARIES := \ + libstagefright_nuplayer \ + libstagefright_rtsp \ + +LOCAL_C_INCLUDES := \ + $(call include-path-for, graphics corecg) \ + $(TOP)/frameworks/av/media/libstagefright/include \ + $(TOP)/frameworks/av/media/libstagefright/rtsp \ + $(TOP)/frameworks/av/media/libstagefright/wifi-display \ + $(TOP)/frameworks/native/include/media/openmax \ + $(TOP)/external/tremolo/Tremolo \ LOCAL_MODULE:= libmediaplayerservice include $(BUILD_SHARED_LIBRARY) include $(call all-makefiles-under,$(LOCAL_PATH)) - diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 6346363..5fe446f 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -70,6 +70,7 @@ #include <OMX.h> #include "Crypto.h" +#include "RemoteDisplay.h" namespace { using android::media::Metadata; @@ -278,6 +279,28 @@ sp<ICrypto> MediaPlayerService::makeCrypto() { return new Crypto; } +status_t MediaPlayerService::enableRemoteDisplay(bool enable) { + Mutex::Autolock autoLock(mLock); + + if (enable && mRemoteDisplay == NULL) { + mRemoteDisplay = new RemoteDisplay; + + status_t err = mRemoteDisplay->start(); + + if (err != OK) { + mRemoteDisplay.clear(); + return err; + } + + return OK; + } else if (!enable && mRemoteDisplay != NULL) { + mRemoteDisplay->stop(); + mRemoteDisplay.clear(); + } + + return OK; +} + status_t MediaPlayerService::AudioCache::dump(int fd, const Vector<String16>& args) const { const size_t SIZE = 256; diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 6ede9a4..8fbc5d5 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -42,6 +42,7 @@ class IMediaRecorder; class IMediaMetadataRetriever; class IOMX; class MediaRecorderClient; +struct RemoteDisplay; #define CALLBACK_ANTAGONIZER 0 #if CALLBACK_ANTAGONIZER @@ -247,6 +248,7 @@ public: virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat); virtual sp<IOMX> getOMX(); virtual sp<ICrypto> makeCrypto(); + virtual status_t enableRemoteDisplay(bool enable); virtual status_t dump(int fd, const Vector<String16>& args); @@ -423,6 +425,7 @@ private: int32_t mNextConnId; sp<IOMX> mOMX; sp<ICrypto> mCrypto; + sp<RemoteDisplay> mRemoteDisplay; }; // ---------------------------------------------------------------------------- diff --git a/media/libmediaplayerservice/RemoteDisplay.cpp b/media/libmediaplayerservice/RemoteDisplay.cpp new file mode 100644 index 0000000..855824a --- /dev/null +++ b/media/libmediaplayerservice/RemoteDisplay.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "RemoteDisplay.h" + +#include "ANetworkSession.h" +#include "source/WifiDisplaySource.h" + +namespace android { + +RemoteDisplay::RemoteDisplay() + : mInitCheck(NO_INIT), + mLooper(new ALooper), + mNetSession(new ANetworkSession), + mSource(new WifiDisplaySource(mNetSession)) { + mLooper->registerHandler(mSource); +} + +RemoteDisplay::~RemoteDisplay() { +} + +status_t RemoteDisplay::start() { + mNetSession->start(); + mLooper->start(); + + // XXX replace with 8554 for bcom dongle (it doesn't respect the + // default port or the one advertised in the wfd IE). + mSource->start(WifiDisplaySource::kWifiDisplayDefaultPort); + + return OK; +} + +status_t RemoteDisplay::stop() { + mSource->stop(); + + mLooper->stop(); + mNetSession->stop(); + + return OK; +} + +} // namespace android + diff --git a/media/libmediaplayerservice/RemoteDisplay.h b/media/libmediaplayerservice/RemoteDisplay.h new file mode 100644 index 0000000..6b37afb --- /dev/null +++ b/media/libmediaplayerservice/RemoteDisplay.h @@ -0,0 +1,54 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef REMOTE_DISPLAY_H_ + +#define REMOTE_DISPLAY_H_ + +#include <media/stagefright/foundation/ABase.h> +#include <utils/Errors.h> +#include <utils/RefBase.h> + +namespace android { + +struct ALooper; +struct ANetworkSession; +struct WifiDisplaySource; + +struct RemoteDisplay : public RefBase { + RemoteDisplay(); + + status_t start(); + status_t stop(); + +protected: + virtual ~RemoteDisplay(); + +private: + status_t mInitCheck; + + sp<ALooper> mNetLooper; + sp<ALooper> mLooper; + sp<ANetworkSession> mNetSession; + sp<WifiDisplaySource> mSource; + + DISALLOW_EVIL_CONSTRUCTORS(RemoteDisplay); +}; + +} // namespace android + +#endif // REMOTE_DISPLAY_H_ + |