@@ -1262,5 +1262,249 @@ index af46d63..efed5a2 100644
1262
1262
client->handlePreviewData(msgType, dataPtr, metadata);
1263
1263
1264
1264
1265
+ From 3ccd91179bff42f704658c5f99c219d5619a0b16 Mon Sep 17 00:00:00 2001
1266
+
1267
+ Date: Sat, 30 Jul 2016 01:54:21 +0200
1268
+ Subject: [PATCH] Add mtk FMRadio support
1269
+
1270
+ Change-Id: I2da5139d71f4afe5a4c3f0f9b43cb44d516fbd18
1271
+ ---
1272
+ include/media/MediaPlayerInterface.h | 3 +
1273
+ media/libmediaplayerservice/Android.mk | 5 +
1274
+ media/libmediaplayerservice/FMAudioPlayer.h | 144 +++++++++++++++++++++
1275
+ media/libmediaplayerservice/MediaPlayerFactory.cpp | 25 ++++
1276
+ 4 files changed, 177 insertions(+)
1277
+ create mode 100644 media/libmediaplayerservice/FMAudioPlayer.h
1278
+
1279
+ diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
1280
+ index 4810b7e..e2fb54d 100644
1281
+ --- a/include/media/MediaPlayerInterface.h
1282
+ +++ b/include/media/MediaPlayerInterface.h
1283
+ @@ -52,6 +52,9 @@ enum player_type {
1284
+ // argument to the 'test:' url in the setDataSource call.
1285
+ TEST_PLAYER = 5,
1286
+ DASH_PLAYER = 6,
1287
+ + #ifdef MTK_HARDWARE
1288
+ + FM_AUDIO_PLAYER = 7,
1289
+ + #endif
1290
+ };
1291
+
1292
+
1293
+ diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
1294
+ index 6575625..08d5326 100644
1295
+ --- a/media/libmediaplayerservice/Android.mk
1296
+ +++ b/media/libmediaplayerservice/Android.mk
1297
+ @@ -58,6 +58,11 @@ LOCAL_C_INCLUDES := \
1298
+ $(TOP)/external/tremolo/Tremolo \
1299
+ $(TOP)/frameworks/av/media/libavextensions \
1300
+
1301
+ + # Mediatek
1302
+ + ifeq ($(strip $(BOARD_HAS_MTK_HARDWARE)),true)
1303
+ + LOCAL_SHARED_LIBRARIES += libmtkplayer
1304
+ + endif
1305
+ +
1306
+ LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall #-DLOG_NDEBUG=0
1307
+ LOCAL_CLANG := true
1308
+
1309
+ diff --git a/media/libmediaplayerservice/FMAudioPlayer.h b/media/libmediaplayerservice/FMAudioPlayer.h
1310
+ new file mode 100644
1311
+ index 0000000..0f239d4
1312
+ --- /dev/null
1313
+ +++ b/media/libmediaplayerservice/FMAudioPlayer.h
1314
+ @@ -0,0 +1,144 @@
1315
+ + /* Copyright Statement:
1316
+ + *
1317
+ + * This software/firmware and related documentation ("MediaTek Software") are
1318
+ + * protected under relevant copyright laws. The information contained herein
1319
+ + * is confidential and proprietary to MediaTek Inc. and/or its licensors.
1320
+ + * Without the prior written permission of MediaTek inc. and/or its licensors,
1321
+ + * any reproduction, modification, use or disclosure of MediaTek Software,
1322
+ + * and information contained herein, in whole or in part, shall be strictly prohibited.
1323
+ + */
1324
+ + /* MediaTek Inc. (C) 2010. All rights reserved.
1325
+ + *
1326
+ + * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
1327
+ + * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
1328
+ + * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
1329
+ + * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
1330
+ + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
1331
+ + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
1332
+ + * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
1333
+ + * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
1334
+ + * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
1335
+ + * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
1336
+ + * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
1337
+ + * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
1338
+ + * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
1339
+ + * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
1340
+ + * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
1341
+ + * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
1342
+ + * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
1343
+ + * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
1344
+ + *
1345
+ + * The following software/firmware and/or related documentation ("MediaTek Software")
1346
+ + * have been modified by MediaTek Inc. All revisions are subject to any receiver's
1347
+ + * applicable license agreements with MediaTek Inc.
1348
+ + */
1349
+ +
1350
+ + #ifndef ANDROID_FM_AUDIOPLAYER_H
1351
+ + #define ANDROID_FM_AUDIOPLAYER_H
1352
+ +
1353
+ +
1354
+ + #include <utils/threads.h>
1355
+ +
1356
+ + #include <media/MediaPlayerInterface.h>
1357
+ + #include <media/AudioTrack.h>
1358
+ + #include <media/AudioRecord.h>
1359
+ +
1360
+ + namespace android
1361
+ + {
1362
+ +
1363
+ + class FMAudioPlayer : public MediaPlayerInterface
1364
+ + {
1365
+ + public:
1366
+ + FMAudioPlayer();
1367
+ + ~FMAudioPlayer();
1368
+ +
1369
+ + virtual void onFirstRef();
1370
+ + virtual status_t initCheck();
1371
+ + //virtual status_t setDataSource(const char *path, const KeyedVector<String8, String8> *headers);
1372
+ + virtual status_t setDataSource(const sp<IMediaHTTPService> &httpService, const char *url, const KeyedVector<String8, String8> *headers);
1373
+ + virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
1374
+ + virtual status_t setVideoSurface(const sp<Surface>& /*surface*/)
1375
+ + {
1376
+ + return UNKNOWN_ERROR;
1377
+ + }
1378
+ + virtual status_t setVideoSurfaceTexture(
1379
+ + const sp<IGraphicBufferProducer>& /*bufferProducer*/)
1380
+ + {
1381
+ + return UNKNOWN_ERROR;
1382
+ + }
1383
+ + virtual status_t prepare();
1384
+ + virtual status_t prepareAsync();
1385
+ + virtual status_t start();
1386
+ + virtual status_t stop();
1387
+ + virtual status_t seekTo(int msec);
1388
+ + virtual status_t pause();
1389
+ + virtual bool isPlaying();
1390
+ + virtual status_t getCurrentPosition(int *msec);
1391
+ + virtual status_t getDuration(int *msec);
1392
+ + virtual status_t release();
1393
+ + virtual status_t reset();
1394
+ + virtual status_t setLooping(int loop);
1395
+ + #ifndef FAKE_FM
1396
+ + virtual status_t setRender(bool enable);
1397
+ + #endif
1398
+ + virtual player_type playerType()
1399
+ + {
1400
+ + return FM_AUDIO_PLAYER;
1401
+ + }
1402
+ + virtual status_t invoke(const Parcel &/*request*/, Parcel */*reply*/)
1403
+ + {
1404
+ + return INVALID_OPERATION;
1405
+ + }
1406
+ + virtual status_t setParameter(int /*key*/, const Parcel &/*request*/)
1407
+ + {
1408
+ + return INVALID_OPERATION;
1409
+ + }
1410
+ + virtual status_t getParameter(int /*key*/, Parcel */*reply*/)
1411
+ + {
1412
+ + return INVALID_OPERATION;
1413
+ + }
1414
+ +
1415
+ + private:
1416
+ + status_t setdatasource(const char *path, int fd, int64_t offset, int64_t length);
1417
+ + status_t reset_nosync();
1418
+ + status_t createOutputTrack();
1419
+ + static int renderThread(void *);
1420
+ + int render();
1421
+ + bool createAudioRecord();
1422
+ + bool deleteAudioRecord();
1423
+ +
1424
+ + #ifndef FAKE_FM
1425
+ + void setHwCallback(bool enable);
1426
+ + #endif
1427
+ +
1428
+ + sp<AudioRecord> mAudioRecord;
1429
+ + Mutex mMutex;
1430
+ + Condition mCondition;
1431
+ + FILE *mFile;
1432
+ + int64_t mOffset;
1433
+ + int64_t mLength;
1434
+ + char *mAudioBuffer;
1435
+ + char *mDummyBuffer;
1436
+ + int mPlayTime;
1437
+ + int mDuration;
1438
+ + uint32_t mFmAudioSamplingRate;
1439
+ +
1440
+ + status_t mState;
1441
+ + int mStreamType;
1442
+ + bool mAndroidLoop;
1443
+ + volatile bool mExit;
1444
+ + bool mPaused;
1445
+ +
1446
+ + bool mSetRender;
1447
+ + volatile bool mRender;
1448
+ + pid_t mRenderTid;
1449
+ + bool flagRecordError;
1450
+ +
1451
+ + int mMutePause;
1452
+ + };
1453
+ +
1454
+ + }; // namespace android
1455
+ +
1456
+ + #endif
1457
+ +
1458
+ +
1459
+ diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
1460
+ index f0afc5a..e378f3c 100644
1461
+ --- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
1462
+ +++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
1463
+ @@ -34,6 +34,10 @@
1464
+ #include "nuplayer/NuPlayerDriver.h"
1465
+ #include <mediaplayerservice/AVMediaServiceExtensions.h>
1466
+
1467
+ + #ifdef MTK_HARDWARE
1468
+ + #include "FMAudioPlayer.h"
1469
+ + #endif
1470
+ +
1471
+ namespace android {
1472
+
1473
+ Mutex MediaPlayerFactory::sLock;
1474
+ @@ -241,6 +245,24 @@ class TestPlayerFactory : public MediaPlayerFactory::IFactory {
1475
+ }
1476
+ };
1477
+
1478
+ + #ifdef MTK_HARDWARE
1479
+ + class FMPlayerFactory : public MediaPlayerFactory::IFactory {
1480
+ + public:
1481
+ + virtual float scoreFactory(const sp<IMediaPlayer>& /*client*/,
1482
+ + const char* url,
1483
+ + float /*curScore*/) {
1484
+ + if(strncmp(url, "MEDIATEK://MEDIAPLAYER_PLAYERTYPE_FM", 36) == 0)
1485
+ + return 1.0;
1486
+ + return 0.0;
1487
+ + }
1488
+ +
1489
+ + virtual sp<MediaPlayerBase> createPlayer(pid_t /* pid */) {
1490
+ + ALOGV("Create FM Player");
1491
+ + return new FMAudioPlayer();
1492
+ + }
1493
+ + };
1494
+ + #endif
1495
+ +
1496
+ void MediaPlayerFactory::registerBuiltinFactories() {
1497
+
1498
+ MediaPlayerFactory::IFactory* pCustomFactory = NULL;
1499
+ @@ -256,6 +278,9 @@ void MediaPlayerFactory::registerBuiltinFactories() {
1500
+ ALOGV("Registering DASH_PLAYER");
1501
+ registerFactory_l(pCustomFactory, DASH_PLAYER);
1502
+ }
1503
+ + #ifdef MTK_HARDWARE
1504
+ + registerFactory_l(new FMPlayerFactory(), FM_AUDIO_PLAYER);
1505
+ + #endif
1506
+
1507
+ sInitComplete = true;
1508
+ }
1265
1509
1266
1510
0 commit comments