From d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 29 Aug 2012 11:41:50 -0700 Subject: Initial checkin of support for acting as a wifi display source Change-Id: I08f17efa0c7d007e17408feb7d4fbef0a19f531a --- media/libmediaplayerservice/Android.mk | 64 +++++++++++----------- media/libmediaplayerservice/MediaPlayerService.cpp | 23 ++++++++ media/libmediaplayerservice/MediaPlayerService.h | 3 + media/libmediaplayerservice/RemoteDisplay.cpp | 56 +++++++++++++++++++ media/libmediaplayerservice/RemoteDisplay.h | 54 ++++++++++++++++++ 5 files changed, 169 insertions(+), 31 deletions(-) create mode 100644 media/libmediaplayerservice/RemoteDisplay.cpp create mode 100644 media/libmediaplayerservice/RemoteDisplay.h (limited to 'media/libmediaplayerservice') 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 #include "Crypto.h" +#include "RemoteDisplay.h" namespace { using android::media::Metadata; @@ -278,6 +279,28 @@ sp 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& 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 decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat); virtual sp getOMX(); virtual sp makeCrypto(); + virtual status_t enableRemoteDisplay(bool enable); virtual status_t dump(int fd, const Vector& args); @@ -423,6 +425,7 @@ private: int32_t mNextConnId; sp mOMX; sp mCrypto; + sp 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 +#include +#include + +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 mNetLooper; + sp mLooper; + sp mNetSession; + sp mSource; + + DISALLOW_EVIL_CONSTRUCTORS(RemoteDisplay); +}; + +} // namespace android + +#endif // REMOTE_DISPLAY_H_ + -- cgit v1.1