美文网首页
BUG分析:

BUG分析:

作者: 小磊长江大 | 来源:发表于2018-05-11 13:44 被阅读0次

    问题4:每次进入播放时上报的本次播放视频ID均为0,期望每次进入播放显示的ID不同

    MediaPlayer.java

        private void setDataSource(String path, String[] keys, String[] values)
                throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
            disableProxyListener();
            getSubtitleService();
    
            final Uri uri = Uri.parse(path);
            if ("file".equals(uri.getScheme())) {
                path = uri.getPath();
            }
    
            final File file = new File(path);
            mPath = path;
            if (file.exists()) {
                FileInputStream is = new FileInputStream(file);
                FileDescriptor fd = is.getFD();
                setDataSource(fd);
                is.close();
            } else {
                _setDataSource(path, keys, values);
            }
    
            String mMesg = new String("setDataSource,url:");
            mMesg = mMesg + path ;
            final String tmpPath = path;
            save_log_in_file(PRINT_LOG_SETPLAYER_SOURCE,mMesg);
            cmd = null;
            cmd = new Intent("MEDIA_PLAY_MONITOR_MESSAGE");
            Looper looper = Looper.getMainLooper();
            Handler xHandler = new Handler(looper) {
                @Override
                public void handleMessage(Message msg) {
                    switch (msg.what) {
                    case 0x2f:
                        Context tmpContetx = ActivityThread.currentApplication()
                                .getApplicationContext();
                        if (!mSendPrepareEvent) {
                            long start = System.currentTimeMillis();
                            Log.d(TAG, "MEDIA_SET_DATASOURCE : "
                                    + mSetDataSourceTime);
                            
                            cmd.putExtra("TYPE", "PLAY_PREPARE");
                            cmd.putExtra("START_TIME", start);
                            cmd.putExtra("URL", tmpPath);
                            //setDataSource时并没有ID,ID在prepare后才产生,因此必须拿上一次的ID+1,或者jni层prepare后拿ID
                            int next_id = SystemProperties.getInt("sys.next.player_id",1);
                            cmd.putExtra("ID", next_id);
                            tmpContetx.sendBroadcast(cmd);
                            mSendPrepareEvent = true;
                        }
                        return;
                    }
                    super.handleMessage(msg);
                }
            };
            Message message = xHandler.obtainMessage(0x2f);
            xHandler.sendMessage(message);
        }
    

    在play start时更新一次ID

    case MEDIA_GET_FIRST_PCR:
                    if(mContext != null){
                        long start = System.currentTimeMillis();
                        int starttime = getCurrentPosition();
                        cmd.putExtra("TYPE", "PLAY_START");
                        cmd.putExtra("PLAY_TIME", starttime/1000);
                        cmd.putExtra("END_TIME", System.currentTimeMillis());
                        info = getMediaInfo();
                        cmd.putExtra("ID", info.player_id);
                        cmd.putExtra("BITRATE", info.bitrate);
                        cmd.putExtra("DURATION", info.duration);
                        SystemProperties.set("sys.next.player_id",String.valueOf(info.player_id + 1));
                        if(info.total_video_num>=1){
                            cmd.putExtra("WIDTH", info.videoInfo[0].width);
                            cmd.putExtra("HEIGHT", info.videoInfo[0].height);
                        }
                        mContext.sendBroadcast(cmd);
                    }
                    return;
    

    AmlogicPlayer.cpp

    mPlayer_id = player_start(&mPlay_ctl, (unsigned long)this);
        if (mPlayer_id >= 0) {
            LOGV("Start player,pid=%d\n", mPlayer_id);
            char str_id[10];
            sprintf(str_id, "%d", mPlayer_id); 
            property_set("sys.next.player_id",str_id);
            if (fastNotifyMode || (PropIsEnable("media.amplayer.fast_prepare",0) && mPlay_ctl.auto_buffing_enable == 1)) {
                sendEvent(MEDIA_PREPARED);
                prepare_complete = bufferGettime();//added for record prepare time
                ALOGE("PRINT_LOG_PREPARED,time=%d\n", (int)(prepare_complete-prepare_start)/1000);
                sendEvent(PRINT_LOG_PREPARED,(int)(prepare_complete-prepare_start)/1000);
            }
            return NO_ERROR;
        }
    

    相关文章

      网友评论

          本文标题:BUG分析:

          本文链接:https://www.haomeiwen.com/subject/vqsfdftx.html