RemoteDisplay.cpp revision d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c
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
22namespace android {
23
24RemoteDisplay::RemoteDisplay()
25    : mInitCheck(NO_INIT),
26      mLooper(new ALooper),
27      mNetSession(new ANetworkSession),
28      mSource(new WifiDisplaySource(mNetSession)) {
29    mLooper->registerHandler(mSource);
30}
31
32RemoteDisplay::~RemoteDisplay() {
33}
34
35status_t RemoteDisplay::start() {
36    mNetSession->start();
37    mLooper->start();
38
39    // XXX replace with 8554 for bcom dongle (it doesn't respect the
40    // default port or the one advertised in the wfd IE).
41    mSource->start(WifiDisplaySource::kWifiDisplayDefaultPort);
42
43    return OK;
44}
45
46status_t RemoteDisplay::stop() {
47    mSource->stop();
48
49    mLooper->stop();
50    mNetSession->stop();
51
52    return OK;
53}
54
55}  // namespace android
56
57