RemoteDisplay.cpp revision 0b73d4730202fcad53aefc4314a06e7b95f442f0
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 "ANetworkSession.h"
20#include "source/WifiDisplaySource.h"
21
22#include <media/IRemoteDisplayClient.h>
23
24namespace android {
25
26RemoteDisplay::RemoteDisplay(
27        const sp<IRemoteDisplayClient> &client, const char *iface)
28    : mLooper(new ALooper),
29      mNetSession(new ANetworkSession),
30      mSource(new WifiDisplaySource(mNetSession, client)) {
31    mLooper->registerHandler(mSource);
32
33    mNetSession->start();
34    mLooper->start();
35
36    mSource->start(iface);
37}
38
39RemoteDisplay::~RemoteDisplay() {
40}
41
42status_t RemoteDisplay::disconnect() {
43    mSource->stop();
44
45    mLooper->stop();
46    mNetSession->stop();
47
48    return OK;
49}
50
51}  // namespace android
52