• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "RemoteDisplay.h"
18 
19 #include "source/WifiDisplaySource.h"
20 
21 #include <media/IRemoteDisplayClient.h>
22 #include <media/stagefright/foundation/ADebug.h>
23 #include <media/stagefright/foundation/AMessage.h>
24 #include <media/stagefright/foundation/ANetworkSession.h>
25 
26 namespace android {
27 
RemoteDisplay(const sp<IRemoteDisplayClient> & client,const char * iface)28 RemoteDisplay::RemoteDisplay(
29         const sp<IRemoteDisplayClient> &client,
30         const char *iface)
31     : mLooper(new ALooper),
32       mNetSession(new ANetworkSession) {
33     mLooper->setName("wfd_looper");
34 
35     mSource = new WifiDisplaySource(mNetSession, client);
36     mLooper->registerHandler(mSource);
37 
38     mNetSession->start();
39     mLooper->start();
40 
41     mSource->start(iface);
42 }
43 
~RemoteDisplay()44 RemoteDisplay::~RemoteDisplay() {
45 }
46 
pause()47 status_t RemoteDisplay::pause() {
48     return mSource->pause();
49 }
50 
resume()51 status_t RemoteDisplay::resume() {
52     return mSource->resume();
53 }
54 
dispose()55 status_t RemoteDisplay::dispose() {
56     mSource->stop();
57     mSource.clear();
58 
59     mLooper->stop();
60     mNetSession->stop();
61 
62     return OK;
63 }
64 
65 }  // namespace android
66