Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | *Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 3 | *Not a Contribution, Apache license notifications and license are retained |
| 4 | *for attribution purposes only. |
| 5 | * |
| 6 | * Copyright (C) 2010 The Android Open Source Project |
| 7 | * |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | */ |
| 20 | |
Shalaj Jain | 6550662 | 2013-01-29 18:27:08 -0800 | [diff] [blame] | 21 | //#define LOG_NDEBUG 0 |
Ajit Khare | 73cfaf4 | 2013-01-07 23:28:47 -0800 | [diff] [blame] | 22 | #define LOG_TAG "DASHFactory" |
| 23 | #include <media/IMediaPlayer.h> |
| 24 | #include <utils/Log.h> |
| 25 | #include "DashPlayerDriver.h" |
| 26 | #include "MediaPlayerFactory.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | class DashPlayerFactory : public MediaPlayerFactory::IFactory { |
| 31 | public: |
| 32 | virtual float scoreFactory(const sp<IMediaPlayer>& client, |
| 33 | const char* url, |
| 34 | float curScore) { |
| 35 | static const float kOurScore = 0.8; |
| 36 | |
| 37 | if (kOurScore <= curScore) |
| 38 | return 0.0; |
| 39 | |
| 40 | if (!strncasecmp("http://", url, 7) |
| 41 | || !strncasecmp("https://", url, 8)) { |
| 42 | size_t len = strlen(url); |
| 43 | if (len >= 5 && !strcasecmp(".mpd", &url[len - 4])) { |
| 44 | return kOurScore; |
| 45 | } |
| 46 | |
| 47 | if (strstr(url,"mpd")) { |
| 48 | return kOurScore; |
| 49 | } |
| 50 | } |
| 51 | return 0.0; |
| 52 | } |
| 53 | |
| 54 | virtual float scoreFactory(const sp<IMediaPlayer>& client, |
| 55 | const sp<IStreamSource> &source, |
| 56 | float curScore) { |
| 57 | return 0.0; |
| 58 | } |
| 59 | |
| 60 | virtual sp<MediaPlayerBase> createPlayer() { |
| 61 | ALOGV("DashPlayerFactory::createPlayer"); |
| 62 | return new DashPlayerDriver; |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | extern "C" MediaPlayerFactory::IFactory* CreateDASHFactory() |
| 67 | { |
| 68 | return new DashPlayerFactory(); |
| 69 | } |
| 70 | |
Shalaj Jain | 6550662 | 2013-01-29 18:27:08 -0800 | [diff] [blame] | 71 | } // namespace android |