blob: 0eb4b5dad03685b259d1a98365de3f96c612eb53 [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(
Svet Ganovbe71aa22015-04-28 12:06:02 -070029 const String16 &opPackageName,
Andreas Huber80600602013-07-18 14:36:18 -070030 const sp<IRemoteDisplayClient> &client,
31 const char *iface)
Andreas Huber0b73d472012-09-05 10:26:52 -070032 : mLooper(new ALooper),
Andreas Huber80600602013-07-18 14:36:18 -070033 mNetSession(new ANetworkSession) {
Andreas Hubere1957352012-09-12 10:19:54 -070034 mLooper->setName("wfd_looper");
Andreas Huber80600602013-07-18 14:36:18 -070035
Svet Ganovbe71aa22015-04-28 12:06:02 -070036 mSource = new WifiDisplaySource(opPackageName, mNetSession, client);
Andreas Huberd7bee3a2012-08-29 11:41:50 -070037 mLooper->registerHandler(mSource);
Andreas Huber0b73d472012-09-05 10:26:52 -070038
39 mNetSession->start();
40 mLooper->start();
41
42 mSource->start(iface);
Andreas Huberd7bee3a2012-08-29 11:41:50 -070043}
44
45RemoteDisplay::~RemoteDisplay() {
46}
47
Andreas Huber5131d122012-11-16 10:38:11 -080048status_t RemoteDisplay::pause() {
49 return mSource->pause();
50}
51
52status_t RemoteDisplay::resume() {
53 return mSource->resume();
54}
55
Jeff Brown455d02e2012-09-05 17:48:03 -070056status_t RemoteDisplay::dispose() {
Andreas Huberd7bee3a2012-08-29 11:41:50 -070057 mSource->stop();
Andreas Huber80600602013-07-18 14:36:18 -070058 mSource.clear();
Andreas Huberd7bee3a2012-08-29 11:41:50 -070059
60 mLooper->stop();
61 mNetSession->stop();
62
63 return OK;
64}
65
66} // namespace android