я пытаюсь вызвать API mediaplayer.cpp для воспроизведения файла mp4.
Но нет изображения, звук выключен и иногда.
#include <sys/stat.h>
#include <fcntl.h>
#include "PlayerListener.h"#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
using namespace std;
using namespace android;
char flag = 0;
CedarMediaPlayer mp;
int main(int argc, char ** argv)
{String8 filepath(argv[1]);
sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();
printf("demo start\n");PlayerListener mPlayerListener;
printf("new a MediaPlayer done\n");mp.setOnPreparedListener(&mPlayerListener);
mp.setOnCompletionListener(&mPlayerListener);
mp.setOnErrorListener(&mPlayerListener);
mp.setOnVideoSizeChangedListener(&mPlayerListener);
mp.setOnInfoListener(&mPlayerListener);
mp.setOnSeekCompleteListener(&mPlayerListener);
mp.setDataSource(filepath);
mp.setLooping(0);
mp.setAudioStreamType(AUDIO_STREAM_MUSIC);
mp.setDisplay(0);
mp.setVolume(0.5f, 0.9f);
printf("set source mp4 done \n");
mp.prepareAsync();
printf("wait huanchong\n\n");
if(flag == 1)
{
printf("i get 1 start \n");
mp.start();
}
// mp.release();
printf("play start\n");
while(1);
return 0;
}
выход logcat:
D/mydemo (106)(f:PlayerListener,l:33)PlayerListener::PlayerListener!
D/mydemo ( 106):
D/ ( 57): has_audio:1 has_video:1
D/CedarXPlayer( 57): =============================================
D/CedarXPlayer( 57): CDX_PLATFORM: A23-JB42
D/CedarXPlayer( 57): CDX_SVN_REPOSITORY: xxxx
D/CedarXPlayer( 57): CDX_SVN_VERSION: xxxx
D/CedarXPlayer( 57): CDX_SVN_COMMITTER: 93eddbd6e60f302b9fcf428e2cdee0eb2dd5925c
D/CedarXPlayer( 57): CDX_SVN_DATE: Mon Aug 24 17:29:52 2015 +0800
D/CedarXPlayer( 57): CDX_RELEASE_AUTHOR: gushiming
D/CedarXPlayer( 57): =============================================
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x0], ret[0x0]
V/aw_demux( 57): DemuxSetDataSource
D/cedarx_demux( 57): cedarx_demux_create: 0x0
D/aw_demux( 57): (f:aw_demux_open, l:848) ==== aw_demux_open url:fd://20?offset=0&length=48098544====
D/awplayer( 57): <CdxParserPrepare:575>: source uri 'fd://20?offset=0&length=48098544'
D/awplayer( 57): <__FileStreamCreate:500>: local file 'fd://20?offset=0&length=48098544'
D/awplayer( 57): <__FileStreamConnect:427>: (21/0/48098544) path:'file:///mnt/extsd/beyond1~1.mp4'
D/awplayer( 57): <__FileStreamConnect:453>: :16:[00 00 00 20 66 74 79 70 69 73 6f 6d 00 00 02 00]
D/awplayer( 57): <__FileStreamGetMetaData:344>: redriect url 'file:///mnt/extsd/beyond1~1.mp4'
D/CdxMovParser( 57): <__CdxMovParserProbe:902>: --- probe: it is mov parser
D/awplayer( 57): <CdxParserCreate:534>: Good, it's 'mov'
D/CdxMovParser( 57): <__CdxMovParserOpen:844>: --- c->bSeekAble = 1
D/awplayer( 57): <CdxParserCreate:537>: parser type(0)
D/awplayer( 57): <MovTop:4988>: ---- compatible = isomiso2avc1mp41
D/awplayer( 57): <MovParseTkhd:2731>: tkhd width = 1024, height = 768
D/awplayer( 57): <MovParseMdhd:2882>: -- language = und
D/awplayer( 57): <MovParseStsd:3670>: stsd width = 1024, height = 768
D/awplayer( 57): <MovParseCtts:4116>: track[0].ctts.entries = 3348
D/awplayer( 57): <MovParseStsz:4048>: -- sample_size = 0
D/awplayer( 57): <MovParseTkhd:2731>: tkhd width = 0, height = 0
D/awplayer( 57): <MovParseMdhd:2882>: -- language = und
D/awplayer( 57): <MovParseStsz:4048>: -- sample_size = 0
D/CdxMovParser( 57): <__CdxMovParserInit:787>: ***** mov open success!!
D/aw_demux( 57): aw_demux_open: aw_dmx->pParser(0x40c58c70), parserType[0], is it forbiden:)?
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:469>: --- codecformat = 115
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:475>: ---- frame rate = 15
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:483>: width = 1024, height = 768
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:486>: extradataSize = 42
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:514>: ********* audio 0************
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:515>: ****eCodecFormat: 4
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:516>: ****eSubCodecFormat: 0
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:517>: ****nChannelNum: 2
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:518>: ****nBitsPerSample: 16
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:519>: ****nSampleRate: 22050
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:520>: ****nAvgBitrate: 0
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:521>: ****nMaxBitRate: 0
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:522>: ****extradataSize 5
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:523>: ***************************
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:563>: streamNum = 2, videoNum = 1, audioNum = 1, subtitleNum = 0
D/awplayer( 57): <CdxMovSetStream:5752>: mvhd = 273200,
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:576>: -- mov duration = 273200
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:592>: --i = 0, stsd_type = 1, stream_index = 0, nb_streams = 2
D/CdxMovParser( 57): <__CdxMovParserGetMediaInfo:592>: --i = 1, stsd_type = 2, stream_index = 0, nb_streams = 2
D/aw_demux( 57): <PrintMediaInfo:363>: *********PrintMediaInfo begin*********
D/aw_demux( 57): <PrintMediaInfo:377>: fileSize = 0, bSeekable = 1, duration = 273200, audioNum = 1, videoNum = 1, subtitleNum = 0
D/aw_demux( 57): <PrintMediaInfo:395>: ***Video[0]*** eCodecFormat = 0x115, nWidth = 1024, nHeight = 768, nFrameRate = 15, nFrameDuration = 0, bIs3DStream = 0
D/aw_demux( 57): <PrintMediaInfo:413>: ***Audio[0]*** eCodecFormat = 0x4, eSubCodecFormat = 0x0, nChannelNum = 2, nBitsPerSample = 16, nSampleRate = 22050
D/aw_demux( 57): <PrintMediaInfo:429>: *********PrintMediaInfo end*********
D/aw_demux( 57): <aw_demux_open:948>: aw_demux_open success.
W/Demux_Component( 57): (f:CreateDemuxPorts, l:906) no subtitle?[0][0]
D/Demux_Component( 57): (f:DemuxGetParameter, l:365) OMX_IndexVendor GetMediaType, default normal tmp
D/CDX_Player( 57): (f:CDXPlayer_GenerateCedarXMediaInformations, l:2075) parser don't care outer rotate, but will process picture self-rotation[0]
D/CedarXPlayer( 57): (f:setNativeWindow_l, l:1013), set layerId[0]
W/CedarXPlayer( 57): (f:prepareAsync, l:1457) property key[media.cedarx.chipver] get value[3], len[1]
D/CedarXPlayer( 57): play vps[0] before CDX CMD_PREPARE_ASYNC!
D/CDX_Player( 57): same vpsspeed[0]
D/CDX_Player( 57): hnd_demuxer 0x40c58980
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x1], ret[0x0]
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x2], ret[0x0]
D/VideoDec_Component( 57): (f:CedarvCodecInit, l:417) vdec output format default to PIXEL_FORMAT_YV12
D/VideoDec_Component( 57): (f:CedarvCodecInit, l:437) config vbvBufferSize[0]KB
E/awplayer( 57): <VeChipId:122>: [40;31mcannot open /dev/sunxi_soc_info
E/awplayer( 57): [0m
D/awplayer( 57): <InitializeVideoDecoder:263>: chipId=0
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x3], ret[0x0]
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x5], ret[0x0]
D/VideoRender_Component( 57): CDX use VideoRenderMode = 0
D/CDX_Component_Common( 57): (f:CDX_CreateComponent, l:57) create component type[0x4], ret[0x0]
D/CDX_Player( 57): components info:[url ], [demux 0x40c58980], [vd 0x41a2a038], [vr 0x40ccc118], [ad 0x40c58f20], [ar 0x40ccc570], [sd 0x0], [sr 0x0]
D/CedarXPlayer( 57): (f:finishAsyncPrepare_l, l:1403) mVideoWidth[1024], mVideoHeight[768], notifyListener_l(MEDIA_SET_VIDEO_SIZE_)
D/mydemo ( 106): (f:onVideoSizeChanged, l:58) receive onVideoSizeChanged message!size[1024x768]
D/mydemo ( 106): (f:onPrepared, l:38) receive onPrepared message! flag = 1
D/CedarXPlayer( 57): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=0!
D/awplayer( 57): <DecodeAudioStream:909>: ==============================pAudioDecoder->pBsInFor->bitrate:5167
D/CedarXPlayer( 57): (f:play_l, l:855) cdx play alread!
W/CDX_Player( 57): only one audio track!
D/AudioRender_Component( 57): >>>>>audio render init sample_rate:22050 channels:2
D/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1199) audio set config start time to [0]us
V/codec_audio_plan_v3( 57): in normal mode, speaker on,****LINE:64,FUNC:set_normal_path, speaker_on=2
D/CedarXPlayer( 57): video render display_size:1024x768, format:0x4
D/CedarXPlayer( 57): (f:StagefrightVideoRenderInit, l:2847) mDisplayFormat[0x32315659], new CedarXDirectHwRenderer
D/HwDisplay( 57): (getInstance 1138)
D/HwDisplay( 57): (hwd_layer_set_src 180)
D/HwDisplay( 57): width: 0x400, height: 0x300
D/HwDisplay( 57): width: 0x40000000000, height: 0x30000000000
D/HwDisplay( 57): set fb.format 88 72 end
W/MediaPlayer( 106): info/warning (3, 0)
I/CedarMediaPlayer( 106): Info (3,0)
D/mydemo ( 106): (f:onInfo, l:64) receive onInfo message! media_info_type[3] extra[0]
D/VideoRender_Component( 57): (f:VideoRender_ComponentThread, l:1291) video set config start time to [133333]us
D/Clock_Component( 57): (f:ClockSetConfig, l:549) notifyStartToRun, Mediatimebase=[0]ms walltimebase=[2171]ms
W/AudioFlinger( 57): write blocked for 1063 msecs, 1 delayed writes, thread 0x40c4dec0
D/audio_hw_primary( 57): out_standby
W/AudioTrack( 57): releaseBuffer() track 0x423ad830 name=0 disabled, restarting
W/AudioFlinger( 57): Thread AudioOut_2 cannot connect to the power manager service
V/codec_audio_plan_v3( 57): in normal mode, speaker on,****LINE:64,FUNC:set_normal_path, speaker_on=2
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[7745]us, because diff[-4195721]us, latency[85034]us, mediaClock[4203566]us
W/VideoRender_Component( 57): (f:VideoRender_ComponentThread, l:1175) videorender sleep too long[220894]us, media_video_time:333333 system_time:112439
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[425705]us, because diff[-955065]us, latency[85034]us, mediaClock[1380870]us
W/AudioTrack( 57): obtainBuffer timed out (is the CPU pegged?) 0x423ad830 name=0user=000030cc, server=00002709
W/AudioFlinger( 57): write blocked for 1081 msecs, 3 delayed writes, thread 0x40c4dec0
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[528879]us, because diff[-974776]us, latency[28299]us, mediaClock[1503755]us
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[565024]us, because diff[-1032425]us, latency[85034]us, mediaClock[1597549]us
W/AudioTrack( 57): obtainBuffer timed out (is the CPU pegged?) 0x423ad830 name=0user=00003a8f, server=000030cc
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[621759]us, because diff[-1098353]us, latency[28299]us, mediaClock[1720212]us
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[657904]us, because diff[-1018148]us, latency[85034]us, mediaClock[1676152]us
W/AudioTrack( 57): obtainBuffer timed out (is the CPU pegged?) 0x423ad830 name=0user=00004452, server=00003a8f
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[676181]us, because diff[-1106519]us, latency[113197]us, mediaClock[1782800]us
W/AudioFlinger( 57): write blocked for 1071 msecs, 6 delayed writes, thread 0x40c4dec0
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[843664]us, because diff[-965500]us, latency[85034]us, mediaClock[1809264]us
W/AudioTrack( 57): obtainBuffer timed out (is the CPU pegged?) 0x423ad830 name=0user=00005568, server=00004ba5
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[946839]us, because diff[-1043967]us, latency[28299]us, mediaClock[1990906]us
W/AudioRender_Component( 57): (f:AudioRender_ComponentThread, l:1361) fatal error! config wall time base again by newTime[1354640]us, because diff[-1034389]us, latency[84897]us, mediaClock[2389129]us
W/AudioFlinger( 57): write blocked for 1058 msecs, 9 delayed writes, thread 0x40c4dec0
Похоже, доступ к памяти пересекает черту Но я не знаю, как решить
2017-2-8 вверх
Но я использую этот код, может успешно воспроизводить файлы aac
./3mydemo1 /mnt/extsd/a.aac
и logcat:
W/AudioFlinger( 58): Thread AudioOut_2 cannot connect to the power manager service
D/mydemo ( 117): (f:PlayerListener, l:33) PlayerListener::PlayerListener!
D/mydemo ( 117):
D/CedarXPlayer( 58): =============================================
D/CedarXPlayer( 58): CDX_PLATFORM: A23-JB42
D/CedarXPlayer( 58): CDX_SVN_REPOSITORY: xxxx
D/CedarXPlayer( 58): CDX_SVN_VERSION: xxxx
D/CedarXPlayer( 58): CDX_SVN_COMMITTER: 93eddbd6e60f302b9fcf428e2cdee0eb2dd5925c
D/CedarXPlayer( 58): CDX_SVN_DATE: Mon Aug 24 17:29:52 2015 +0800
D/CedarXPlayer( 58): CDX_RELEASE_AUTHOR: gushiming
D/CedarXPlayer( 58): =============================================
D/CDX_Component_Common( 58): (f:CDX_CreateComponent, l:57) create component type[0x0], ret[0x0]
V/aw_demux( 58): DemuxSetDataSource
D/cedarx_demux( 58): cedarx_demux_create: 0x0
D/aw_demux( 58): (f:aw_demux_open, l:848) ==== aw_demux_open url:fd://22?offset=0&length=7182674====
D/awplayer( 58): <CdxParserPrepare:575>: source uri 'fd://22?offset=0&length=7182674'
D/awplayer( 58): <__FileStreamCreate:500>: local file 'fd://22?offset=0&length=7182674'
D/awplayer( 58): <__FileStreamConnect:427>: (23/0/7182674) path:'file:///mnt/extsd/a.aac'
D/awplayer( 58): <__FileStreamConnect:453>: :16:[ff f1 50 80 3e 7f fc de 02 00 4c 61 76 63 35 37]
D/awplayer( 58): <__FileStreamGetMetaData:344>: redriect url 'file:///mnt/extsd/a.aac'
W/awplayer( 58): <__AacParserProbe:1615>: aac probe ok.
D/awplayer( 58): <CdxParserCreate:534>: Good, it's 'aac'
D/awplayer( 58): <CdxParserCreate:537>: parser type(22)
W/awplayer( 58): <__AacParserControl:1297>: not implement...(265)
W/awplayer( 58): <AacInit:1227>: AAC ulDuration:289386
D/aw_demux( 58): aw_demux_open: aw_dmx->pParser(0x411f17a0), parserType[22], is it forbiden:)?
D/aw_demux( 58): <PrintMediaInfo:363>: *********PrintMediaInfo begin*********
D/aw_demux( 58): <PrintMediaInfo:377>: fileSize = 7182674, bSeekable = 1, duration = 289386, audioNum = 1, videoNum = 0, subtitleNum = 0
D/aw_demux( 58): <PrintMediaInfo:413>: ***Audio[0]*** eCodecFormat = 0xf, eSubCodecFormat = 0x0, nChannelNum = 2, nBitsPerSample = 16, nSampleRate = 44100
D/aw_demux( 58): <PrintMediaInfo:429>: *********PrintMediaInfo end*********
D/aw_demux( 58): <aw_demux_open:948>: aw_demux_open success.
W/Demux_Component( 58): (f:CreateDemuxPorts, l:870) no video?[0][0]
W/Demux_Component( 58): (f:CreateDemuxPorts, l:906) no subtitle?[0][0]
D/Demux_Component( 58): (f:DemuxGetParameter, l:365) OMX_IndexVendor GetMediaType, default normal tmp
D/CedarXPlayer( 58): (f:setNativeWindow_l, l:1013), set layerId[0]
W/CedarXPlayer( 58): (f:prepareAsync, l:1457) property key[media.cedarx.chipver] get value[3], len[1]
D/CedarXPlayer( 58): play vps[0] before CDX CMD_PREPARE_ASYNC!
D/CDX_Player( 58): same vpsspeed[0]
D/CDX_Player( 58): hnd_demuxer 0x4119ec68
D/CDX_Component_Common( 58): (f:CDX_CreateComponent, l:57) create component type[0x1], ret[0x0]
D/CDX_Component_Common( 58): (f:CDX_CreateComponent, l:57) create component type[0x3], ret[0x0]
D/CDX_Component_Common( 58): (f:CDX_CreateComponent, l:57) create component type[0x4], ret[0x0]
D/CDX_Player( 58): components info:[url ], [demux 0x4119ec68], [vd 0x0], [vr 0x0], [ad 0x4119e758], [ar 0x41207d70], [sd 0x0], [sr 0x0]
W/CedarXPlayer( 58): unkown video size after prepared
D/mydemo ( 117): (f:onPrepared, l:38) receive onPrepared message! flag = 1
D/CedarXPlayer( 58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=0!
D/awplayer( 58): <DecodeAudioStream:909>: ==============================pAudioDecoder->pBsInFor->bitrate:171921
D/CedarXPlayer( 58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=1!
D/AudioRender_Component( 58): >>>>>audio render init sample_rate:44100 channels:2
D/AudioRender_Component( 58): (f:AudioRender_ComponentThread, l:1199) audio set config start time to [0]us
D/Clock_Component( 58): (f:ClockSetConfig, l:549) notifyStartToRun, Mediatimebase=[0]ms walltimebase=[20]ms
V/codec_audio_plan_v3( 58): in normal mode, speaker on,****LINE:64,FUNC:set_normal_path, speaker_on=2
D/CedarXPlayer( 58): (f:play_l, l:855) cdx play alread!
W/CDX_Player( 58): only one audio track!
Так что я думаю, что трансграничная память видео выхода MP4 произошло
Задача ещё не решена.
Других решений пока нет …