1d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber/*
2d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * Copyright 2012, The Android Open Source Project
3d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber *
4d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * you may not use this file except in compliance with the License.
6d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * You may obtain a copy of the License at
7d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber *
8d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber *     http://www.apache.org/licenses/LICENSE-2.0
9d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber *
10d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * Unless required by applicable law or agreed to in writing, software
11d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * See the License for the specific language governing permissions and
14d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber * limitations under the License.
15d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber */
16d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
17d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber#include "RemoteDisplay.h"
18d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
19d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber#include "source/WifiDisplaySource.h"
20d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
210b73d4730202fcad53aefc4314a06e7b95f442f0Andreas Huber#include <media/IRemoteDisplayClient.h>
228060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber#include <media/stagefright/foundation/ADebug.h>
238060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber#include <media/stagefright/foundation/AMessage.h>
248060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber#include <media/stagefright/foundation/ANetworkSession.h>
250b73d4730202fcad53aefc4314a06e7b95f442f0Andreas Huber
26d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Hubernamespace android {
27d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
280b73d4730202fcad53aefc4314a06e7b95f442f0Andreas HuberRemoteDisplay::RemoteDisplay(
298060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber        const sp<IRemoteDisplayClient> &client,
308060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber        const char *iface)
310b73d4730202fcad53aefc4314a06e7b95f442f0Andreas Huber    : mLooper(new ALooper),
328060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber      mNetSession(new ANetworkSession) {
33e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    mLooper->setName("wfd_looper");
348060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber
358060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber    mSource = new WifiDisplaySource(mNetSession, client);
36d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mLooper->registerHandler(mSource);
37d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
38d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mNetSession->start();
39d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mLooper->start();
40d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
41bcf09f8c995221e75c7cd328f25c7cc6d2b5f7c9Andreas Huber    mSource->start(iface);
420b73d4730202fcad53aefc4314a06e7b95f442f0Andreas Huber}
43d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
440b73d4730202fcad53aefc4314a06e7b95f442f0Andreas HuberRemoteDisplay::~RemoteDisplay() {
45d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber}
46d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
475131d127a042ee88f903370be88845dc8c9f8578Andreas Huberstatus_t RemoteDisplay::pause() {
485131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    return mSource->pause();
495131d127a042ee88f903370be88845dc8c9f8578Andreas Huber}
505131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
515131d127a042ee88f903370be88845dc8c9f8578Andreas Huberstatus_t RemoteDisplay::resume() {
525131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    return mSource->resume();
535131d127a042ee88f903370be88845dc8c9f8578Andreas Huber}
545131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
55455d02eca342d8159637af317a5d83219d267812Jeff Brownstatus_t RemoteDisplay::dispose() {
56d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mSource->stop();
578060060217ff16cd67c8f6a15c649f44c343acf0Andreas Huber    mSource.clear();
58d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
59d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mLooper->stop();
60d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    mNetSession->stop();
61d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
62d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber    return OK;
63d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber}
64d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber
65d7bee3a9d2ad76d073d91f0ee36d5ac5f9df480cAndreas Huber}  // namespace android
66