blob: eb959b40def9309566cc8c4404e45ce0760bcf4c [file] [log] [blame]
Andreas Huberd7bee3a2012-08-29 11:41:50 -07001/*
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
Andreas Huberd7bee3a2012-08-29 11:41:50 -070019#include "source/WifiDisplaySource.h"
20
Andreas Huber0b73d472012-09-05 10:26:52 -070021#include <media/IRemoteDisplayClient.h>
Andreas Huber80600602013-07-18 14:36:18 -070022#include <media/stagefright/foundation/ADebug.h>
23#include <media/stagefright/foundation/AMessage.h>
24#include <media/stagefright/foundation/ANetworkSession.h>
Andreas Huber0b73d472012-09-05 10:26:52 -070025
Andreas Huberd7bee3a2012-08-29 11:41:50 -070026namespace android {
27
Andreas Huber0b73d472012-09-05 10:26:52 -070028RemoteDisplay::RemoteDisplay(
Andreas Huber80600602013-07-18 14:36:18 -070029 const sp<IRemoteDisplayClient> &client,
30 const char *iface)
Andreas Huber0b73d472012-09-05 10:26:52 -070031 : mLooper(new ALooper),
Andreas Huber80600602013-07-18 14:36:18 -070032 mNetSession(new ANetworkSession) {
Andreas Hubere1957352012-09-12 10:19:54 -070033 mLooper->setName("wfd_looper");
Andreas Huber80600602013-07-18 14:36:18 -070034
35 mSource = new WifiDisplaySource(mNetSession, client);
Andreas Huberd7bee3a2012-08-29 11:41:50 -070036 mLooper->registerHandler(mSource);
Andreas Huber0b73d472012-09-05 10:26:52 -070037
38 mNetSession->start();
39 mLooper->start();
40
41 mSource->start(iface);
Andreas Huberd7bee3a2012-08-29 11:41:50 -070042}
43
44RemoteDisplay::~RemoteDisplay() {
45}
46
Andreas Huber5131d122012-11-16 10:38:11 -080047status_t RemoteDisplay::pause() {
48 return mSource->pause();
49}
50
51status_t RemoteDisplay::resume() {
52 return mSource->resume();
53}
54
Jeff Brown455d02e2012-09-05 17:48:03 -070055status_t RemoteDisplay::dispose() {
Andreas Huberd7bee3a2012-08-29 11:41:50 -070056 mSource->stop();
Andreas Huber80600602013-07-18 14:36:18 -070057 mSource.clear();
Andreas Huberd7bee3a2012-08-29 11:41:50 -070058
59 mLooper->stop();
60 mNetSession->stop();
61
62 return OK;
63}
64
65} // namespace android