HiPlayOSSSDK.java 源代码


package com.hichip.sdk;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.ServiceException;
import com.hichip.AesCode.DoAes;
import com.hichip.base.HiLog;
import com.hichip.base.HiThread;
import com.hichip.callback.PlayOSSFileCallback;
import com.hichip.coder.EncMp4;
import com.hichip.coder.H264Decoder;
import com.hichip.coder.HiCoderBitmap;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCloud;
import com.hichip.control.HiGLMonitor;
import com.hichip.data.FrameData;
import com.hichip.data.FrameQueue;
import com.hichip.data.HiAudioPlay;
import com.hichip.data.HiDeviceInfo;
import com.hichip.data.Oss2File;
import com.hichip.data.Oss2FileQueue;
import com.hichip.system.HiSystemValue;
import com.hichip.tools.HiCloudSDK;
import com.hichip.tools.HiConfig;
import com.hichip.tools.Packet;
import com.hichip.tools.PlayLocalFile;
import common.HiDataValue;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.Timer;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.litepal.util.Const;

public class HiPlayOSSSDK implements Serializable {
    private static final int HANDLE_MESSAGE_cloud_RESULT = 268435458;
    private static final int HANDLE_MESSAGE_manage_RESULT = 268435457;
    private String filepath;
    private int filetime;
    private String localfilepathoss;
    private Context mContext;
    private String mSaveFilepath;
    private HiCloud mhiCloud;
    private String mhiCloudname;
    private String mhiCloudpwd;
    private HiCloudSDK mhiCloudsdk;
    private HiConfig mhiConfig;
    private int videoheight;
    private int videowidth;
    private ThreadPlayLocal threadPlayLocal = null;
    private ThreadDecodeVideo threadDecodeVideo = null;
    private ThreadDecodeAudio threadDecodeAudio = null;
    private ThreadOSSDown mthreadOSSDowndata = null;
    private ThreadOSSDownFileList mthreadOSSDownFileList = null;
    private ThreadOSSDownFileTime mthreadOSSDownFileTime = null;
    private ThreadOSSDownCustom mthreadOSSDownCustomFile = null;
    private ThreadOSSdoesobj mthreadossdoesobj = null;
    private ThreadOSSFileList mthreadossfilelist = null;
    private ThreadManageOSS mthreadmanageoss = null;
    private FrameQueue mossVideoFrameQueue = null;
    private FrameQueue mossAudioFrameQueue = null;
    private HiGLMonitor mMonitor = null;
    private int audiotype = -1;
    private int videotype = -1;
    private long saveFirstTime = 0;
    int video_type = -1;
    int savespeed = 0;
    int saveInterval = 50;
    private boolean isPlaying = true;
    private boolean isPlayEnd = false;
    private int saveflag = 0;
    private boolean isSeek = false;
    private boolean isSeekend = false;
    private boolean isSpeed = false;
    private int s32SecPerFrame = 0;
    private boolean SaveisSeek = false;
    private int SaveSeekTime = 0;
    private int VIDEO_TYPE_MP4 = 0;
    private int VIDEO_TYPE_AVI = 1;
    private int VIDEO_TYPE_H264 = 2;
    private boolean isPlayStop = false;
    private boolean is2Mp4 = false;
    long[] mp4_handle = new long[1];
    private boolean isOpenFile = false;
    private int DecodeVideoType = 0;
    private int DecodeViVoVideoType = 1;
    private Lock writemp4lock = new ReentrantLock();
    private int maxlen = 0;
    private int subtime = 0;
    private int mFirstTime = 0;
    private boolean isLoading_FLAG = false;
    private boolean isDisplayFrist = false;
    private int Loading_IFrameNum = 0;
    private int Loading_IFrameNum_tal = 3;
    private int Loading_FrameNum = 100;
    private int Loading_FramePts = 5;
    private ThreadDecodeAudioCloud mThreadDecodeAudioCloud = null;
    private ThreadDecodeVideoCloud mThreadDecodeVideoCloud = null;
    private Oss2FileQueue mOssFrameQueue = null;
    private HiChipDefines.HI_Oss_DownLoad2File mOssDLFile = null;
    private String mhiCloudSer = "120.24.156.39";
    private int mhiCloudport = 33201;
    private String mhiCloudKey = "701-jpzh";
    private boolean isOSSFile = false;
    private int SaveOssLoad = 0;
    private int saveOssLoadLen = 0;
    private boolean OSSLoadFin = false;
    private boolean isPlayossEnd = false;
    private boolean isOssreadHead_end = false;
    private String Savedownload_file = "";
    private int mOssLoadSt = 0;
    private int mOssLoadEn = 0;
    private int mOssFilesize = 0;
    private boolean isExitOSSLoad = false;
    private int saveframeseekpos = 0;
    private long mSaveOssGetTime = 0;
    private long mSetOsstime = 300000;
    private int mosstokentime = 60;
    private int mOssOperation = 0;
    private boolean mOSSSaveisSeek = false;
    private int u32AVFramePTS1 = 0;
    private boolean isDeviceDecode5 = true;
    private byte[] yuvBuffer = null;
    private int cumtimeout = 10000;
    private int mcumCount = 3;
    private int mcumCounttry = 0;
    private int mstartrecvdata = 0;
    private boolean mOssDownEnd = false;
    private boolean mOssThreadExit = false;
    private HiDeviceInfo mDeciveInfo = new HiDeviceInfo();
    private boolean isqueueenpty = false;
    private PlayOSSFileCallback mplayOSSfilecallback = null;
    private Timer mUidEXIPREtimer = null;
    private boolean mIsOCloud = false;
    private String mOCloudDate = "";
    private String mOCloudUid = "";
    long[] osswrite_readhandle = new long[1];
    long[] ossread_readhandle = new long[1];
    long[] mp4_readhandle = new long[1];
    long[] avi_readhandle = new long[1];
    long[] h264_readhandle = new long[1];
    private boolean isH265DevDec = false;
    private HiGLMonitor mMonitorSpliceview = null;
    private boolean mSpliceDev = false;
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            switch (i) {
                case 24831:
                    long[] jArr = (long[]) message.obj;
                    HiPlayOSSSDK.this.setOSSDownLoadProgres(message.what, jArr[0], jArr[1]);
                    HiPlayOSSSDK.this.mstartrecvdata = message.what;
                    return;
                case 24832:
                    HiPlayOSSSDK.this.mOssThreadExit = false;
                    HiLog.e("" + message.what, 1, 0);
                    HiPlayOSSSDK.this.setOSSReq(((ClientException) message.obj).toString(), message.what, -1, -1);
                    return;
                case HiChipDefines.HI_P2P_GET_SNAP_AUTO_PARAM:
                    HiPlayOSSSDK.this.mOssThreadExit = false;
                    HiLog.e("" + message.what, 1, 0);
                    HiPlayOSSSDK.this.setOSSReq(((ServiceException) message.obj).toString(), message.what, -1, -1);
                    return;
                case HiChipDefines.HI_P2P_SET_SNAP_AUTO_PARAM:
                    HiPlayOSSSDK.this.mOssThreadExit = false;
                    HiLog.e("" + message.what, 1, 0);
                    HiPlayOSSSDK.this.setOSSReq(((IOException) message.obj).toString(), message.what, -1, -1);
                    return;
                case HiChipDefines.HI_P2P_GET_SNAP_AUTO_SCHEDULE:
                    HiPlayOSSSDK.this.mOssThreadExit = false;
                    HiLog.e("" + message.what, 1, 0);
                    HiPlayOSSSDK.this.setOSSReq("", message.what, -1, -1);
                    return;
                case HiChipDefines.HI_P2P_SET_SNAP_AUTO_SCHEDULE:
                    HiLog.e("" + message.what, 1, 0);
                    HiPlayOSSSDK.this.setOSSReq("", message.what, -1, -1);
                    return;
                default:
                    switch (i) {
                        case 25087:
                            break;
                        case 25088:
                            break;
                        case 25089:
                            break;
                        case 25090:
                            break;
                        case 25091:
                            break;
                        case 25092:
                            break;
                        default:
                            switch (i) {
                                case 25343:
                                    break;
                                case 25344:
                                    break;
                                case 25345:
                                    break;
                                case 25346:
                                    break;
                                case 25347:
                                    break;
                                case 25348:
                                    break;
                                default:
                                    switch (i) {
                                        case 25599:
                                            break;
                                        case 25600:
                                            break;
                                        case 25601:
                                            break;
                                        case 25602:
                                            break;
                                        case 25603:
                                            break;
                                        case 25604:
                                            break;
                                        default:
                                            switch (i) {
                                                case 25855:
                                                    break;
                                                case 25856:
                                                    break;
                                                case 25857:
                                                    break;
                                                case 25858:
                                                    break;
                                                case 25859:
                                                    break;
                                                case 25860:
                                                    break;
                                                default:
                                                    switch (i) {
                                                        case 26111:
                                                            break;
                                                        case 26112:
                                                            break;
                                                        case 26113:
                                                            break;
                                                        case 26114:
                                                            break;
                                                        case 26115:
                                                            break;
                                                        case 26116:
                                                            break;
                                                        default:
                                                            return;
                                                    }
                                            }
                                    }
                            }
                    }
            }
        }
    };
    private Handler cumhandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            HiLog.e("" + message.what, 1, 0);
            int i = message.what;
            if (i != 28672 && i != 28673) {
                switch (i) {
                    case 28928:
                    case HiChipDefines.HI_P2P_GET_FTP_PARAM:
                        break;
                    case HiChipDefines.HI_P2P_SET_FTP_PARAM:
                        HiLog.e("" + message.what, 1, 0);
                        HiPlayOSSSDK.this.setOSSReq("", message.what, 1, 1);
                        return;
                    case HiChipDefines.HI_P2P_GET_EMAIL_PARAM:
                        HiLog.e("" + message.what, 1, 0);
                        HiPlayOSSSDK.this.setOSSReq("", message.what, 1, 1);
                        return;
                    default:
                        return;
                }
            }
            HiLog.e("" + message.what, 1, 0);
            HiPlayOSSSDK.this.setOSSReq("", message.what, -1, -1);
        }
    };

    public void DoRead264File(HiThread hiThread) {
    }

    public void DoReadAVIFile(HiThread hiThread) {
    }

    public void DoReadMp4File(HiThread hiThread) {
    }

    private int Playlocal_OpenAVI(String str) {
        return 1;
    }

    public void registerPlayOSSStateListener(PlayOSSFileCallback playOSSFileCallback) {
        this.mplayOSSfilecallback = playOSSFileCallback;
        HiLog.e("" + playOSSFileCallback, 1, 0);
    }

    public void unregisterPlayOSSStateListener(PlayOSSFileCallback playOSSFileCallback) {
        this.mplayOSSfilecallback = null;
        HiLog.e("" + playOSSFileCallback, 1, 0);
    }

    public void SetOSSverdueTime(long j) {
        HiLog.e("" + this.mSetOsstime, 1, 0);
        this.mSetOsstime = j;
        HiLog.e("" + this.mSetOsstime, 1, 0);
    }

    public void SetDotryCount(int i) {
        this.mcumCount = i;
    }

    public void OSSOperation() {
        switch (this.mOssOperation) {
            case 1:
                GetOSSFileTime(0, 0);
                break;
            case 2:
                GetOSSFileList("", 0, 0);
                break;
            case 3:
                OSSPlayDown("", "", "", 0, 0);
                break;
            case 4:
                StartOSSDownCustomFile("", 0, 0);
                break;
            case 5:
                GetOSSFilelistExt("", 0);
                break;
            case 6:
                GetOSSdoesObjectExt("", 0);
                break;
        }
        this.mOssOperation = 0;
    }

    private void SetCallResult(final Context context) {
        this.mhiCloudsdk.SetCallResult(new HiCloudSDK.ICloudResult() {
            @Override
            public void onReceiveiCloudResult(String str, int i, int i2, int i3, String str2) {
                HiLog.e(str + ":::" + i + ":::" + i2 + "::" + i3, 1, 0);
                if (i == 1) {
                    if (i2 == 0 && i3 >= 0) {
                        HiPlayOSSSDK.this.mhiCloudSer = str;
                        HiPlayOSSSDK.this.mhiCloudport = i3;
                        HiPlayOSSSDK.this.mhiCloudKey = str2;
                        if (HiPlayOSSSDK.this.mhiConfig != null) {
                            HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_UUID() + "::" + HiPlayOSSSDK.this.mhiConfig.getOSSServer() + ":::" + HiPlayOSSSDK.this.mhiConfig.getOssport() + "::::" + HiPlayOSSSDK.this.mhiConfig.getAeskey(), 1, 0);
                            HiCloudSDK hiCloudSDK = HiPlayOSSSDK.this.mhiCloudsdk;
                            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
                            hiCloudSDK.HiCloudSDKgetCloudinfo(hiPlayOSSSDK, 0, hiPlayOSSSDK.mhiConfig.getOSS_UUID(), HiPlayOSSSDK.this.mhiCloudname, HiPlayOSSSDK.this.mhiCloudpwd, HiPlayOSSSDK.this.mhiCloudKey, HiPlayOSSSDK.this.mhiCloudSer, HiPlayOSSSDK.this.mhiCloudport, (short) 5);
                        }
                    }
                    HiPlayOSSSDK.this.setOSSReq(str, i, i2, i3);
                    return;
                }
                if (i == 2) {
                    if (i2 == 0) {
                        if (HiPlayOSSSDK.this.mhiConfig == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME() == null || HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT().length() <= 0) {
                            HiPlayOSSSDK.this.setOSSReq(str, i, -1, -1);
                            HiLog.e("", 1, 1);
                            return;
                        }
                        HiPlayOSSSDK.this.mhiCloud.initOSS(context, HiPlayOSSSDK.this.mhiConfig);
                        HiPlayOSSSDK.this.mSaveOssGetTime = System.currentTimeMillis();
                        HiLog.e("" + HiPlayOSSSDK.this.mOssOperation, 1, 0);
                        if (HiPlayOSSSDK.this.mOssOperation != 0) {
                            HiPlayOSSSDK.this.OSSOperation();
                            return;
                        } else {
                            HiPlayOSSSDK.this.setOSSReq(str, i, i2, i3);
                            return;
                        }
                    }
                    HiPlayOSSSDK.this.setOSSReq(str, i, i2, i3);
                }
            }

            @Override
            public void onReceiveiOCloudResult(String str, int i, int i2, int i3, String str2, int i4) {
                if (i == 4) {
                    if (i2 == 0) {
                        if (HiPlayOSSSDK.this.mhiConfig == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME() == null || HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME().length() <= 0 || HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT() == null || HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT().length() <= 0) {
                            HiPlayOSSSDK.this.setOSSOCloudReq(str, i, -1, -1, i4);
                            HiLog.e("", 1, 1);
                            return;
                        }
                        HiPlayOSSSDK.this.mhiCloud.initOSS(context, HiPlayOSSSDK.this.mhiConfig);
                        HiPlayOSSSDK.this.mSaveOssGetTime = System.currentTimeMillis();
                        HiLog.e("" + HiPlayOSSSDK.this.mOssOperation, 1, 0);
                        HiLog.e("" + HiPlayOSSSDK.this.mOssOperation + "u32GmtTime:" + i4 + "szGmtTime" + str2 + "EndTime:" + i3, 1, 0);
                        if (i3 - i4 < 3600) {
                            HiPlayOSSSDK.this.mSetOsstime = 3000000L;
                        }
                        if (HiPlayOSSSDK.this.mOssOperation != 0) {
                            HiPlayOSSSDK.this.OSSOperation();
                            HiLog.e("" + HiPlayOSSSDK.this.mOssOperation + "u32GmtTime:" + i4 + "szGmtTime" + str2, 1, 0);
                            HiPlayOSSSDK.this.setOSSOCloudReq(str, 41, i2, i3, i4);
                            return;
                        }
                        HiLog.e("" + HiPlayOSSSDK.this.mOssOperation + "u32GmtTime:" + i4 + "szGmtTime" + str2, 1, 0);
                        HiPlayOSSSDK.this.setOSSOCloudReq(str, i, i2, i3, i4);
                        return;
                    }
                    HiLog.e("" + HiPlayOSSSDK.this.mOssOperation + "ret:" + i2 + "status:" + i3 + "u32GmtTime:" + i4, 1, 0);
                    HiPlayOSSSDK.this.setOSSOCloudReq(str, i, i2, i3, i4);
                }
            }
        });
    }

    public long dateToStamp(String str) throws ParseException {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.getDefault()).parse(str + " +0000"));
        return calendar.getTimeInMillis();
    }

    public void SetContext(Context context, String str) {
        this.mContext = context;
        if (this.mOssFrameQueue == null) {
            this.mOssFrameQueue = new Oss2FileQueue();
        }
        if (this.mOssDLFile == null) {
            this.mOssDLFile = new HiChipDefines.HI_Oss_DownLoad2File();
        }
        if (this.mhiConfig == null) {
            this.mhiConfig = new HiConfig();
        }
        if (str != null) {
            this.mhiConfig.setOSS_UUID(str);
        } else {
            this.mhiConfig.setOSS_UUID("BBBB-000000-CDEFG");
        }
        if (this.mhiCloudsdk == null) {
            this.mhiCloudsdk = new HiCloudSDK();
        }
        if (this.mhiCloud == null) {
            this.mhiCloud = new HiCloud();
        }
        HiLog.e("", 1, 0);
        SetCallResult(context);
    }

    public boolean GetOSSisInfo() {
        HiCloud hiCloud = this.mhiCloud;
        return (hiCloud == null || hiCloud.mOSS == null) ? false : true;
    }

    public void GetOSSInfo(String str, String str2, int i) {
        this.isOSSFile = true;
        this.SaveOssLoad = 0;
        this.OSSLoadFin = false;
        this.isPlayossEnd = false;
        this.isOssreadHead_end = false;
        this.saveOssLoadLen = 0;
        this.mOssLoadEn = 0;
        this.mOssLoadSt = 0;
        this.mOssFilesize = 0;
        this.isPlayStop = false;
        this.mhiCloudname = str;
        this.mhiCloudpwd = str2;
        this.mIsOCloud = false;
        HiCloud hiCloud = this.mhiCloud;
        if (hiCloud != null && hiCloud.mOSS != null) {
            HiLog.e("", 1, 1);
            return;
        }
        if (1 == i) {
            this.mhiCloudSer = "39.98.69.40";
            this.mhiCloudport = 33201;
            this.mhiCloudKey = "701-jpzh";
            HiLog.e(this.mhiConfig.getOSS_UUID() + "::" + this.mhiConfig.getOSSServer() + ":::" + this.mhiConfig.getOssport() + "::::" + this.mhiConfig.getAeskey(), 1, 0);
            this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
            return;
        }
        this.mhiCloudsdk.HiCloudSDKgetmanageinfo(this, 0, this.mhiConfig.getOSS_UUID());
    }

    public void GetOSSInfoOCloud(String str, String str2, String str3, int i, int i2, int i3) {
        this.isOSSFile = true;
        this.SaveOssLoad = 0;
        this.OSSLoadFin = false;
        this.isPlayossEnd = false;
        this.isOssreadHead_end = false;
        this.saveOssLoadLen = 0;
        this.mOssLoadEn = 0;
        this.mOssLoadSt = 0;
        this.mOssFilesize = 0;
        this.isPlayStop = false;
        this.mhiCloudname = str;
        this.mhiCloudpwd = str2;
        Timer timer = this.mUidEXIPREtimer;
        if (timer != null) {
            timer.cancel();
        }
        this.mUidEXIPREtimer = null;
        HiCloud hiCloud = this.mhiCloud;
        if (hiCloud != null && hiCloud.mOSS != null) {
            HiLog.e("", 1, 1);
            return;
        }
        if (1 != i2) {
            this.mhiCloudsdk.HiCloudSDKgetmanageinfo(this, 0, this.mhiConfig.getOSS_UUID());
            return;
        }
        if (i3 > 0) {
            this.mIsOCloud = true;
            if (str3 != null && !TextUtils.isEmpty(str3)) {
                this.mhiCloudSer = str3;
            } else {
                this.mhiCloudSer = "8.209.77.99";
            }
            if (i > 0) {
                this.mhiCloudport = i;
            } else {
                this.mhiCloudport = 33375;
            }
            this.mhiCloudKey = "";
            HiLog.e(this.mhiConfig.getOSS_UUID() + "::" + this.mhiConfig.getOSSServer() + ":::" + this.mhiConfig.getOssport() + "::::" + this.mhiConfig.getAeskey(), 1, 0);
            this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
            return;
        }
        this.mIsOCloud = false;
        if (str3 != null && !TextUtils.isEmpty(str3)) {
            this.mhiCloudSer = str3;
        } else {
            this.mhiCloudSer = "39.98.69.40";
        }
        if (i > 0) {
            this.mhiCloudport = i;
        } else {
            this.mhiCloudport = 33201;
        }
        this.mhiCloudKey = "701-jpzh";
        HiLog.e(this.mhiConfig.getOSS_UUID() + "::" + this.mhiConfig.getOSSServer() + ":::" + this.mhiConfig.getOssport() + "::::" + this.mhiConfig.getAeskey(), 1, 0);
        this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
    }

    public void SetOSSOCloudDate(String str, String str2, boolean z) {
        this.mIsOCloud = z;
        this.mOCloudDate = str2;
        this.mOCloudUid = str;
    }

    private void ParseTimeList(byte[] bArr, int i, int i2) {
        if (i <= 0) {
            setOSSData(3, new byte[0], 0, 0, 0, 0, 0, -1);
        }
        int i3 = i / 12;
        HiLog.e("" + i + ":::::" + i3, 1, 0);
        byte[] bArr2 = new byte[12];
        byte[] bArr3 = new byte[8];
        byte b = -1;
        if (i3 > 0) {
            int i4 = 0;
            while (i4 < i3) {
                System.arraycopy(bArr, i4 * 12, bArr2, 0, 12);
                System.arraycopy(bArr2, 0, bArr3, 0, 8);
                byte b2 = bArr2[9];
                HiLog.e("" + i4 + ":::::::" + new String(bArr2) + "::::" + ((int) b2), 1, 0);
                setOSSData(3, bArr3, 0, b2, 0, 0, 0, 1);
                i4++;
                bArr3 = bArr3;
                b = b2;
            }
        }
        byte[] bArr4 = bArr3;
        byte b3 = b;
        if (2 == i2) {
            setOSSData(3, bArr4, 0, b3, 0, 0, 0, 2);
        }
    }

    public void parserecdata(byte[] bArr, int i) {
        HiLog.e(";;;;;" + i + "::" + new String(bArr), 1, 0);
        if (i == 1) {
            byte[] bArr2 = new byte[128];
            System.arraycopy(bArr, 0, bArr2, 0, 128);
            this.mOssFilesize = Packet.byteArrayToInt_Little(bArr, 128);
            int byteArrayToInt_Little = Packet.byteArrayToInt_Little(bArr, 132);
            int byteArrayToInt_Little2 = Packet.byteArrayToInt_Little(bArr, 136);
            int byteArrayToInt_Little3 = Packet.byteArrayToInt_Little(bArr, 140);
            int byteArrayToInt_Little4 = Packet.byteArrayToInt_Little(bArr, 144);
            HiLog.e("u32FileSize:" + this.mOssFilesize + "RecType" + byteArrayToInt_Little + "u32StartTime" + byteArrayToInt_Little2 + "u32EndTime" + byteArrayToInt_Little3 + "u32Resv" + byteArrayToInt_Little4, 1, 0);
            setOSSData(1, bArr2, this.mOssFilesize, byteArrayToInt_Little, byteArrayToInt_Little2, byteArrayToInt_Little3, byteArrayToInt_Little4, 0);
            return;
        }
        if (i != 2) {
            return;
        }
        int i2 = 4;
        int byteArrayToInt_Little5 = Packet.byteArrayToInt_Little(bArr, 4);
        int byteArrayToInt_Little6 = Packet.byteArrayToInt_Little(bArr, 8);
        int byteArrayToInt_Little7 = Packet.byteArrayToInt_Little(bArr, 12);
        int byteArrayToInt_Little8 = Packet.byteArrayToInt_Little(bArr, 0);
        int byteArrayToInt_Little9 = Packet.byteArrayToInt_Little(bArr, 16);
        if (byteArrayToInt_Little8 == 1414944840) {
            i2 = 5;
        }
        int i3 = i2;
        setOSSData(2, new byte[1], byteArrayToInt_Little5, byteArrayToInt_Little6, i3, byteArrayToInt_Little7, byteArrayToInt_Little9, 0);
        HiLog.e("" + i3 + ":::" + byteArrayToInt_Little5 + ":::" + byteArrayToInt_Little6 + ":::" + byteArrayToInt_Little7 + ":::" + byteArrayToInt_Little9, 1, 0);
        PlayLocalFile.HiH264WriteOSS(this.osswrite_readhandle[0], bArr, 20, 0);
    }

    public void GetOSSFileTime(int i, int i2) {
        String replaceAll;
        this.mstartrecvdata = 0;
        if (i != 0) {
            this.mcumCounttry = 0;
        }
        HiLog.e(i + "::::" + System.currentTimeMillis() + ":::::" + System.nanoTime(), 1, 0);
        if (System.currentTimeMillis() - this.mSaveOssGetTime > ((this.mosstokentime * 60) * 1000) - this.mSetOsstime) {
            if (this.mIsOCloud) {
                Timer timer = this.mUidEXIPREtimer;
                if (timer != null) {
                    timer.cancel();
                }
                this.mUidEXIPREtimer = null;
                this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
            } else {
                this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
            }
            this.mOssOperation = 1;
            return;
        }
        HiConfig hiConfig = this.mhiConfig;
        if (hiConfig != null) {
            hiConfig.setOSS_objectKey(this.mhiConfig.getOSS_UUID() + "/recdate.db");
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            HiLog.e(this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
            HiLog.e(this.mhiConfig.getBUCKET_NAME(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
            ThreadOSSDownFileTime threadOSSDownFileTime = this.mthreadOSSDownFileTime;
            if (threadOSSDownFileTime != null) {
                threadOSSDownFileTime.weakup();
                this.mthreadOSSDownFileTime.stopThread();
                this.mthreadOSSDownFileTime = null;
            }
            if (this.mthreadOSSDownFileTime == null) {
                ThreadOSSDownFileTime threadOSSDownFileTime2 = new ThreadOSSDownFileTime();
                this.mthreadOSSDownFileTime = threadOSSDownFileTime2;
                if (i != 0 && i2 != 0) {
                    threadOSSDownFileTime2.SetNeedLen(i2);
                }
                this.mthreadOSSDownFileTime.startThread();
            }
        }
    }

    public void GetOSSFileList(String str, int i, int i2) {
        String replaceAll;
        HiLog.e("" + i, 1, 0);
        this.mstartrecvdata = 0;
        if (i != 0) {
            this.mcumCounttry = 0;
        }
        if (this.mhiConfig != null) {
            HiLog.e("" + str + "::::" + this.isPlayStop, 1, 0);
            if (i != 0) {
                if (str != null) {
                    this.mhiConfig.setOSS_objectKey(this.mhiConfig.getOSS_UUID() + "/" + str + "/recdata.db");
                } else {
                    this.mhiConfig.setOSS_objectKey("BBBB-000000-CDEFG/20190729/recdata.db");
                }
            }
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            HiLog.e(this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
            HiLog.e(this.mhiConfig.getBUCKET_NAME(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_objectKey(), 1, 0);
            if (System.currentTimeMillis() - this.mSaveOssGetTime > ((this.mosstokentime * 60) * 1000) - this.mSetOsstime) {
                if (this.mIsOCloud) {
                    Timer timer = this.mUidEXIPREtimer;
                    if (timer != null) {
                        timer.cancel();
                    }
                    this.mUidEXIPREtimer = null;
                    this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                } else {
                    this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                }
                this.mOssOperation = 2;
                return;
            }
            ThreadOSSDownFileList threadOSSDownFileList = this.mthreadOSSDownFileList;
            if (threadOSSDownFileList != null) {
                threadOSSDownFileList.weakup();
                this.mthreadOSSDownFileList.stopThread();
                this.mthreadOSSDownFileList = null;
            }
            if (this.mthreadOSSDownFileList == null) {
                ThreadOSSDownFileList threadOSSDownFileList2 = new ThreadOSSDownFileList();
                this.mthreadOSSDownFileList = threadOSSDownFileList2;
                if (i != 0 && i2 != 0) {
                    threadOSSDownFileList2.SetNeedLen(i2);
                }
                this.mthreadOSSDownFileList.startThread();
            }
        }
    }

    public void OSSPlayDown(String str, String str2, String str3, int i, int i2) {
        String replaceAll;
        HiLog.e("" + i2 + "dddd" + str + "dddd" + str2 + "dddd" + str3 + "dddd" + i + "::::" + this.mOssThreadExit, 1, 0);
        if (i2 != 0) {
            this.mcumCounttry = 0;
        }
        if (this.mhiConfig != null) {
            if (i2 != 0) {
                if (!this.Savedownload_file.equals(str)) {
                    this.mOssFrameQueue.removeAll();
                    this.Savedownload_file = str;
                }
                this.mOssFilesize = i;
                this.localfilepathoss = str2 + str3;
                this.mhiConfig.setOSS_objectKey(str);
            }
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            ThreadManageOSS threadManageOSS = this.mthreadmanageoss;
            if (threadManageOSS != null) {
                this.mOssThreadExit = false;
                threadManageOSS.weakup();
                this.mthreadmanageoss.stopThread();
                this.mthreadmanageoss = null;
            }
            if (this.mthreadmanageoss == null) {
                ThreadManageOSS threadManageOSS2 = new ThreadManageOSS();
                this.mthreadmanageoss = threadManageOSS2;
                threadManageOSS2.startThread();
            }
        }
    }

    public int StartOSSDownCustomFile(String str, int i, int i2) {
        String replaceAll;
        HiLog.e("" + i2, 1, 0);
        if (i2 != 0) {
            this.mcumCounttry = 0;
        }
        if (str == null) {
            HiLog.e("", 1, 1);
            return -1;
        }
        if (this.mhiConfig != null) {
            HiLog.e("" + str + "::::" + this.isPlayStop, 1, 0);
            if (i2 != 0) {
                this.mhiConfig.setOSS_objectKey(str);
            }
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            HiLog.e(this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
            HiLog.e(this.mhiConfig.getBUCKET_NAME(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
            if (System.currentTimeMillis() - this.mSaveOssGetTime > ((this.mosstokentime * 60) * 1000) - this.mSetOsstime) {
                if (this.mIsOCloud) {
                    Timer timer = this.mUidEXIPREtimer;
                    if (timer != null) {
                        timer.cancel();
                    }
                    this.mUidEXIPREtimer = null;
                    this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                } else {
                    this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                }
                this.mOssOperation = 4;
            } else {
                ThreadOSSDownCustom threadOSSDownCustom = this.mthreadOSSDownCustomFile;
                if (threadOSSDownCustom != null) {
                    threadOSSDownCustom.weakup();
                    this.mthreadOSSDownCustomFile.stopThread();
                    this.mthreadOSSDownCustomFile = null;
                }
                if (this.mthreadOSSDownCustomFile == null) {
                    ThreadOSSDownCustom threadOSSDownCustom2 = new ThreadOSSDownCustom();
                    this.mthreadOSSDownCustomFile = threadOSSDownCustom2;
                    if (i2 != 0 && i != 0) {
                        threadOSSDownCustom2.SetNeedLen(i);
                    }
                    this.mthreadOSSDownCustomFile.startThread();
                }
            }
            return 0;
        }
        HiLog.e("", 1, 1);
        return -2;
    }

    public void StopOSSDownCustomFile() {
        this.isPlayStop = true;
        ThreadOSSDownCustom threadOSSDownCustom = this.mthreadOSSDownCustomFile;
        if (threadOSSDownCustom != null) {
            threadOSSDownCustom.weakup();
            this.mthreadOSSDownCustomFile.stopThread();
            this.mthreadOSSDownCustomFile = null;
        }
    }

    public void setOSSData(int i, byte[] bArr, int i2, int i3, int i4, int i5, int i6, int i7) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.callbackOSSData(i, bArr, i2, i3, i4, i5, i6, i7, this.mhiConfig.getOSS_objectKey());
        }
    }

    public void setOSSReq(String str, int i, int i2, int i3) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.callbackOSSReq(str, i, i2, i3, this.mhiConfig.getOSS_objectKey());
        }
    }

    public void setOSSOCloudReq(String str, int i, int i2, int i3, int i4) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.callbackOSSOCloudReq(str, i, i2, i3, i4, this.mhiConfig.getOSS_objectKey());
        }
    }

    public void setOSSDownLoad(int i, int i2, int i3) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.CallBackOSSDownLoad(i, i2, i3, this.mhiConfig.getOSS_objectKey());
        }
    }

    public void setOSSDownLoadProgres(int i, long j, long j2) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.CallBackOSSDownLoadExt(i, j, j2, this.mhiConfig.getOSS_objectKey());
        }
    }

    private void setplaylocal(int i, int i2, int i3, long j, int i4, int i5) {
        PlayOSSFileCallback playOSSFileCallback = this.mplayOSSfilecallback;
        if (playOSSFileCallback != null) {
            playOSSFileCallback.callbackplaylocalExt(i, i2, i3, this.saveFirstTime, j, i4, i5, this.mSaveFilepath);
        }
    }

    public void setLiveShowMonitor(HiGLMonitor hiGLMonitor) {
        if (hiGLMonitor == null) {
            HiLog.e("", 1, 1);
            return;
        }
        this.mMonitor = hiGLMonitor;
        HiLog.e("setLiveShowMonitor" + hiGLMonitor.getWidth() + "" + hiGLMonitor.getHeight(), 1, 0);
    }

    public void setLiveSpliceShowMonitor(boolean z, HiGLMonitor hiGLMonitor) {
        this.mMonitorSpliceview = hiGLMonitor;
        this.mSpliceDev = z;
    }

    public void setMonitorNull() {
        if (this.mMonitor != null) {
            this.mMonitor = null;
        }
        if (this.mMonitorSpliceview != null) {
            this.mMonitorSpliceview = null;
        }
    }

    public int Start2Mp4(String str, String str2) {
        HiLog.e("" + str, 1, 0);
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.mOssDownEnd = false;
        this.isOpenFile = true;
        this.savespeed = 0;
        this.saveInterval = 50;
        this.isPlaying = true;
        this.saveflag = 0;
        this.isSeek = false;
        this.isSpeed = false;
        this.isPlayEnd = false;
        this.SaveisSeek = false;
        this.SaveSeekTime = 0;
        this.is2Mp4 = true;
        this.isSeekend = false;
        this.isPlayStop = false;
        this.isLoading_FLAG = false;
        this.mSaveFilepath = str;
        this.isqueueenpty = false;
        String substring = str.substring(str.length() - 4, str.length());
        HiLog.e("" + str, 1, 0);
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            int Playlocal_OpenAVI = Playlocal_OpenAVI(str);
            if (Playlocal_OpenAVI != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenAVI;
            }
        } else {
            if (substring.equals(".mp4")) {
                this.video_type = this.VIDEO_TYPE_MP4;
                return -1;
            }
            if (str.contains(".ch26x")) {
                this.OSSLoadFin = true;
                this.isOSSFile = true;
            }
            if (this.OSSLoadFin) {
                this.mOssDownEnd = true;
            }
            this.video_type = this.VIDEO_TYPE_H264;
            int Playlocal_OpenH264 = Playlocal_OpenH264(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        }
        long[] jArr = this.mp4_handle;
        jArr[0] = 0;
        int HIEncMp4init = EncMp4.HIEncMp4init(jArr, this.videowidth, this.videoheight, str2, 0);
        if (HIEncMp4init != 0) {
            setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, 0, -11);
            Stop2Mp4();
            HiLog.e("", 1, 1);
            return HIEncMp4init;
        }
        HiLog.e("", 1, 0);
        this.saveFirstTime = GetOSSFileFirstTime();
        startThread();
        return HIEncMp4init;
    }

    public int Stop2Mp4() {
        this.isOpenFile = false;
        this.isPlayStop = true;
        stopThread();
        ThreadOSSDown threadOSSDown = this.mthreadOSSDowndata;
        if (threadOSSDown != null) {
            threadOSSDown.weakup();
            this.mthreadOSSDowndata.stopThread();
            this.mthreadOSSDowndata = null;
        }
        HiLog.e("", 1, 0);
        this.video_type = -1;
        return 0;
    }

    public long GetOSSFileFirstTime() {
        long[] jArr = new long[4];
        PlayLocalFile.HiH264FindIFrameOSS(this.ossread_readhandle[0], -1, jArr);
        return jArr[2];
    }

    public int GetFileTime(String str) {
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.isOpenFile = true;
        HiLog.e("" + str, 1, 0);
        int[] iArr = new int[10];
        iArr[4] = -1;
        String substring = str.substring(str.length() - 4, str.length());
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            long[] jArr = this.avi_readhandle;
            jArr[0] = 0;
            int HiAVICreateReader = PlayLocalFile.HiAVICreateReader(jArr, str);
            if (HiAVICreateReader != 0) {
                HiLog.e("", 1, 1);
                return HiAVICreateReader;
            }
            int HiAVIGetInfo = PlayLocalFile.HiAVIGetInfo(str, iArr);
            PlayLocalFile.HiAVIDestroyReader(this.avi_readhandle[0]);
            if (HiAVIGetInfo != 0) {
                this.isOpenFile = false;
                HiLog.e("", 1, 1);
                return HiAVIGetInfo;
            }
        } else if (substring.equals(".mp4")) {
            this.video_type = this.VIDEO_TYPE_MP4;
            long[] jArr2 = this.mp4_readhandle;
            jArr2[0] = 0;
            int HIEncMp4CreateReader2 = EncMp4.HIEncMp4CreateReader2(jArr2, str, iArr);
            EncMp4.HIEncMp4DestroyReader2(this.mp4_readhandle[0]);
            if (HIEncMp4CreateReader2 != 0) {
                this.isOpenFile = false;
                return HIEncMp4CreateReader2;
            }
        } else {
            this.video_type = this.VIDEO_TYPE_H264;
            long[] jArr3 = this.ossread_readhandle;
            jArr3[0] = 0;
            int HiH264CreateReaderOSS = PlayLocalFile.HiH264CreateReaderOSS(jArr3, str);
            if (HiH264CreateReaderOSS != 0) {
                this.isOpenFile = false;
                HiLog.e("", 1, 1);
                return HiH264CreateReaderOSS;
            }
            int HiH264GetInfoOSSExt = PlayLocalFile.HiH264GetInfoOSSExt(str, iArr);
            PlayLocalFile.HiH264DestroyReaderOSS(this.ossread_readhandle[0]);
            if (HiH264GetInfoOSSExt != 0) {
                this.isOpenFile = false;
                HiLog.e("", 1, 1);
                return HiH264GetInfoOSSExt;
            }
        }
        this.videowidth = iArr[0];
        this.videoheight = iArr[1];
        if (substring.equals(".mp4")) {
            this.filetime = iArr[2] / 1000;
        } else {
            this.filetime = iArr[2];
        }
        this.audiotype = iArr[4];
        if (iArr[3] != 0) {
            this.s32SecPerFrame = 1000 / iArr[3];
        } else {
            this.s32SecPerFrame = 1000;
        }
        HiLog.e("" + this.videowidth + ":::" + this.videoheight + ":::" + this.filetime + ":::" + iArr[3] + ":::" + this.audiotype + ":::" + iArr[5], 1, 0);
        this.isOpenFile = false;
        return this.filetime;
    }

    public int StartPlayLocal(String str) {
        int Playlocal_OpenH264;
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.mOssDownEnd = false;
        this.isOpenFile = true;
        this.savespeed = 0;
        this.saveInterval = 50;
        this.isPlaying = true;
        this.saveflag = 0;
        this.isSeek = false;
        this.isSpeed = false;
        this.isPlayEnd = false;
        this.SaveisSeek = false;
        this.SaveSeekTime = 0;
        this.is2Mp4 = false;
        this.isSeekend = false;
        this.isPlayStop = false;
        this.mSaveFilepath = str;
        this.subtime = 0;
        this.mFirstTime = 0;
        this.isqueueenpty = false;
        HiLog.e(this.isOSSFile + "::::" + str, 1, 0);
        String substring = str.substring(str.length() + (-4), str.length());
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            Playlocal_OpenH264 = Playlocal_OpenAVI(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else if (substring.equals(".mp4")) {
            this.video_type = this.VIDEO_TYPE_MP4;
            Playlocal_OpenH264 = Playlocal_OpenMp4(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else {
            if (str.contains(".ch26x")) {
                this.OSSLoadFin = true;
                this.isOSSFile = true;
            }
            if (this.OSSLoadFin) {
                this.mOssDownEnd = true;
            }
            this.video_type = this.VIDEO_TYPE_H264;
            Playlocal_OpenH264 = Playlocal_OpenH264(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        }
        HiLog.e("" + this.video_type, 1, 0);
        this.saveFirstTime = GetOSSFileFirstTime();
        startThread();
        return Playlocal_OpenH264;
    }

    public int StartPlayLocalExt(String str, int i) {
        int Playlocal_OpenH264;
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.mOssDownEnd = false;
        this.isOpenFile = true;
        this.savespeed = 0;
        this.saveInterval = 50;
        this.isPlaying = true;
        this.saveflag = 0;
        this.isSeek = false;
        this.isSpeed = false;
        this.isPlayEnd = false;
        this.SaveisSeek = false;
        this.SaveSeekTime = 0;
        this.is2Mp4 = false;
        this.isSeekend = false;
        this.isPlayStop = false;
        this.mSaveFilepath = str;
        this.subtime = 0;
        this.isqueueenpty = false;
        if (i <= 0) {
            this.mFirstTime = 0;
        } else {
            this.mFirstTime = i;
        }
        HiLog.e(this.isOSSFile + "::::" + str, 1, 0);
        String substring = str.substring(str.length() + (-4), str.length());
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            Playlocal_OpenH264 = Playlocal_OpenAVI(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else if (substring.equals(".mp4")) {
            this.video_type = this.VIDEO_TYPE_MP4;
            Playlocal_OpenH264 = Playlocal_OpenMp4(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else {
            if (str.contains(".ch26x")) {
                this.OSSLoadFin = true;
                this.isOSSFile = true;
            }
            if (this.OSSLoadFin) {
                this.mOssDownEnd = true;
            }
            this.video_type = this.VIDEO_TYPE_H264;
            Playlocal_OpenH264 = Playlocal_OpenH264(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        }
        HiLog.e("" + this.video_type, 1, 0);
        this.saveFirstTime = GetOSSFileFirstTime();
        startThread();
        return Playlocal_OpenH264;
    }

    public int StartPlayLocalTime(String str, int i) {
        int Playlocal_OpenH264;
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.mOssDownEnd = false;
        this.isOpenFile = true;
        this.savespeed = 0;
        this.saveInterval = 50;
        this.isPlaying = true;
        this.saveflag = 0;
        this.isSeek = false;
        this.isSpeed = false;
        this.isPlayEnd = false;
        this.SaveisSeek = false;
        this.SaveSeekTime = 0;
        this.is2Mp4 = false;
        this.isSeekend = false;
        this.isPlayStop = false;
        this.mSaveFilepath = str;
        this.isqueueenpty = false;
        if (i > 0) {
            this.SaveSeekTime = i;
            this.SaveisSeek = true;
        }
        HiLog.e(this.isOSSFile + "::::" + str + ":::::" + i, 1, 0);
        String substring = str.substring(str.length() + (-4), str.length());
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            Playlocal_OpenH264 = Playlocal_OpenAVI(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else if (substring.equals(".mp4")) {
            this.video_type = this.VIDEO_TYPE_MP4;
            Playlocal_OpenH264 = Playlocal_OpenMp4(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else {
            if (str.contains(".ch26x")) {
                this.OSSLoadFin = true;
                this.isOSSFile = true;
            }
            if (this.OSSLoadFin) {
                this.mOssDownEnd = true;
            }
            this.video_type = this.VIDEO_TYPE_H264;
            Playlocal_OpenH264 = Playlocal_OpenH264(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        }
        HiLog.e("" + this.video_type, 1, 0);
        this.saveFirstTime = GetOSSFileFirstTime();
        startThread();
        return Playlocal_OpenH264;
    }

    public int StartPlayLocalTimeExt(String str, int i, int i2) {
        int Playlocal_OpenH264;
        if (this.isOpenFile) {
            HiLog.e("", 1, 1);
            return -1;
        }
        this.mOssDownEnd = false;
        this.isOpenFile = true;
        this.savespeed = 0;
        this.saveInterval = 50;
        this.isPlaying = true;
        this.saveflag = 0;
        this.isSeek = false;
        this.isSpeed = false;
        this.isPlayEnd = false;
        this.SaveisSeek = false;
        this.SaveSeekTime = 0;
        this.is2Mp4 = false;
        this.isSeekend = false;
        this.isPlayStop = false;
        this.isqueueenpty = false;
        this.mSaveFilepath = str;
        if (i > 0) {
            this.SaveSeekTime = i;
            this.SaveisSeek = true;
        }
        if (i2 <= 0) {
            this.mFirstTime = 0;
        } else {
            this.mFirstTime = i2;
        }
        HiLog.e(this.isOSSFile + "::::" + str + ":::::" + i, 1, 0);
        String substring = str.substring(str.length() + (-4), str.length());
        if (substring.equals(".avi")) {
            this.video_type = this.VIDEO_TYPE_AVI;
            Playlocal_OpenH264 = Playlocal_OpenAVI(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else if (substring.equals(".mp4")) {
            this.video_type = this.VIDEO_TYPE_MP4;
            Playlocal_OpenH264 = Playlocal_OpenMp4(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        } else {
            if (str.contains(".ch26x")) {
                this.OSSLoadFin = true;
                this.isOSSFile = true;
            }
            if (this.OSSLoadFin) {
                this.mOssDownEnd = true;
            }
            this.video_type = this.VIDEO_TYPE_H264;
            Playlocal_OpenH264 = Playlocal_OpenH264(str);
            if (Playlocal_OpenH264 != 0) {
                HiLog.e("", 1, 1);
                return Playlocal_OpenH264;
            }
        }
        HiLog.e("" + this.video_type, 1, 0);
        this.saveFirstTime = GetOSSFileFirstTime();
        startThread();
        return Playlocal_OpenH264;
    }

    public int StopDownOSS() {
        String str;
        HiLog.e("StopDownOSS", 1, 0);
        this.mOssThreadExit = false;
        ThreadManageOSS threadManageOSS = this.mthreadmanageoss;
        if (threadManageOSS != null) {
            threadManageOSS.weakup();
            this.mthreadmanageoss.stopThread();
            this.mthreadmanageoss = null;
        }
        ThreadOSSDown threadOSSDown = this.mthreadOSSDowndata;
        if (threadOSSDown != null) {
            threadOSSDown.weakup();
            this.mthreadOSSDowndata.stopThread();
            this.mthreadOSSDowndata = null;
        }
        ThreadOSSDownFileTime threadOSSDownFileTime = this.mthreadOSSDownFileTime;
        if (threadOSSDownFileTime != null) {
            threadOSSDownFileTime.weakup();
            this.mthreadOSSDownFileTime.stopThread();
            this.mthreadOSSDownFileTime = null;
        }
        ThreadOSSDownFileList threadOSSDownFileList = this.mthreadOSSDownFileList;
        if (threadOSSDownFileList != null) {
            threadOSSDownFileList.weakup();
            this.mthreadOSSDownFileList.stopThread();
            this.mthreadOSSDownFileList = null;
        }
        HiLog.e(this.saveOssLoadLen + "::::" + this.mOssFilesize, 1, 0);
        if (this.isOSSFile && (str = this.localfilepathoss) != null && this.saveOssLoadLen != this.mOssFilesize) {
            delFile(str);
        }
        return 1;
    }

    public int StopPlayLocal() {
        String str;
        HiLog.e("" + this.isOSSFile, 1, 0);
        this.mOssDownEnd = false;
        this.isOpenFile = false;
        this.isPlayStop = true;
        stopThread();
        HiLog.e("" + this.video_type + ":::" + this.localfilepathoss, 1, 0);
        if (this.isOSSFile && (str = this.localfilepathoss) != null && this.saveOssLoadLen == this.mOssFilesize) {
            if (str.contains(HiDataValue.OSSFILEEn)) {
                String str2 = this.localfilepathoss;
                renameFile(str2, str2.replace(HiDataValue.OSSFILEEn, HiDataValue.OSSFILEEnd));
            } else {
                String str3 = this.localfilepathoss;
                renameFile(str3, str3.replace(HiDataValue.OSSFILEEn_HX, HiDataValue.OSSFILEEnd));
            }
        }
        HiLog.e("0", 1, 0);
        this.video_type = -1;
        this.mossVideoFrameQueue = null;
        this.mossAudioFrameQueue = null;
        return 0;
    }

    public Bitmap getSnapshot() {
        HiLog.e("saveSnapshot", 1, 0);
        ThreadDecodeVideoCloud threadDecodeVideoCloud = this.mThreadDecodeVideoCloud;
        if (threadDecodeVideoCloud == null) {
            HiLog.e("", 1, 1);
            return null;
        }
        byte[] yuvBuffer = threadDecodeVideoCloud.getYuvBuffer();
        if (yuvBuffer == null) {
            HiLog.e("", 1, 1);
            return null;
        }
        int i = this.videowidth;
        int i2 = this.videoheight;
        if (i <= 0 || i2 <= 0 || i > 5000 || i2 > 5000) {
            HiLog.e("", 1, 1);
            return null;
        }
        HiLog.e("getSnapshot:" + i + "heigth:" + i2, 1, 0);
        byte[] MallocByte = Packet.MallocByte(i * i2 * 3);
        if (MallocByte == null) {
            return null;
        }
        HiLog.e("getSnapshot:" + i + "heigth:" + i2, 1, 0);
        HiCoderBitmap.YUVToRGB565(yuvBuffer, i, i2, MallocByte);
        HiLog.e("getSnapshot:" + i + "heigth:" + i2, 1, 0);
        ByteBuffer wrap = ByteBuffer.wrap(MallocByte);
        Bitmap createBitmap = Bitmap.createBitmap(i, i2, Bitmap.Config.RGB_565);
        if (wrap != null) {
            createBitmap.copyPixelsFromBuffer(wrap);
        }
        return createBitmap;
    }

    private void startThread() {
        ThreadPlayLocal threadPlayLocal = this.threadPlayLocal;
        if (threadPlayLocal == null) {
            ThreadPlayLocal threadPlayLocal2 = new ThreadPlayLocal();
            this.threadPlayLocal = threadPlayLocal2;
            threadPlayLocal2.startThread();
        } else {
            threadPlayLocal.isRunning = true;
            DoReadOSS264File(this.threadPlayLocal);
        }
        HiLog.e("", 1, 0);
        if (!this.isOSSFile) {
            if (this.threadDecodeVideo == null) {
                ThreadDecodeVideo threadDecodeVideo = new ThreadDecodeVideo();
                this.threadDecodeVideo = threadDecodeVideo;
                threadDecodeVideo.startThread();
            }
            HiLog.e("", 1, 0);
            if (this.threadDecodeAudio == null) {
                ThreadDecodeAudio threadDecodeAudio = new ThreadDecodeAudio();
                this.threadDecodeAudio = threadDecodeAudio;
                threadDecodeAudio.startThread();
                return;
            }
            return;
        }
        startPlaybackThread();
    }

    private void stopThread() {
        HiLog.e("", 1, 0);
        ThreadPlayLocal threadPlayLocal = this.threadPlayLocal;
        if (threadPlayLocal != null) {
            threadPlayLocal.weakup();
            this.threadPlayLocal.stopThread();
            this.threadPlayLocal = null;
        }
        if (!this.isOSSFile) {
            ThreadDecodeVideo threadDecodeVideo = this.threadDecodeVideo;
            if (threadDecodeVideo != null) {
                threadDecodeVideo.stopThread();
                this.threadDecodeVideo = null;
            }
            ThreadDecodeAudio threadDecodeAudio = this.threadDecodeAudio;
            if (threadDecodeAudio != null) {
                threadDecodeAudio.stopThread();
                this.threadDecodeAudio = null;
            }
        } else {
            stopPlaybackThread();
        }
        HiLog.e("", 1, 0);
        FrameQueue frameQueue = this.mossVideoFrameQueue;
        if (frameQueue != null) {
            frameQueue.removeAll();
        }
        HiLog.e("", 1, 0);
        FrameQueue frameQueue2 = this.mossAudioFrameQueue;
        if (frameQueue2 != null) {
            frameQueue2.removeAll();
        }
        HiLog.e("", 1, 0);
    }

    private int Playlocal_CloseAVI() {
        return PlayLocalFile.HiAVIDestroyReader(this.avi_readhandle[0]);
    }

    private int Playlocal_OpenH264(String str) {
        int[] iArr = new int[10];
        long[] jArr = this.ossread_readhandle;
        jArr[0] = 0;
        int HiH264CreateReaderOSS = PlayLocalFile.HiH264CreateReaderOSS(jArr, str);
        if (HiH264CreateReaderOSS != 0) {
            HiLog.e("", 1, 1);
            return HiH264CreateReaderOSS;
        }
        int HiH264GetInfoOSSExt = PlayLocalFile.HiH264GetInfoOSSExt(str, iArr);
        if (HiH264GetInfoOSSExt != 0) {
            HiLog.e("", 1, 1);
            return HiH264GetInfoOSSExt;
        }
        HiLog.e("sWidth:" + iArr[0] + "::sHeight:" + iArr[1] + "::sTime:" + iArr[2] + "::dwRate:" + iArr[3] + "::sAudioType:" + iArr[4] + "::sVideoType:" + iArr[5], 1, 0);
        if (!this.is2Mp4) {
            setplaylocal(iArr[0], iArr[1], iArr[2], 0L, iArr[4], 0);
        } else {
            setplaylocal(iArr[0], iArr[1], iArr[2], 0L, iArr[4], 10);
        }
        this.videowidth = iArr[0];
        this.videoheight = iArr[1];
        this.filetime = iArr[2];
        this.audiotype = iArr[4];
        int i = iArr[5] == 5 ? 5 : 4;
        this.videotype = i;
        if (5 == i && Build.VERSION.SDK_INT >= 23) {
            this.isH265DevDec = true;
        }
        if (this.mossVideoFrameQueue == null) {
            this.mossVideoFrameQueue = new FrameQueue();
        }
        if (this.mossAudioFrameQueue == null) {
            this.mossAudioFrameQueue = new FrameQueue();
        }
        if (this.isOSSFile) {
            this.isDisplayFrist = false;
            FrameQueue frameQueue = this.mossVideoFrameQueue;
            if (frameQueue != null) {
                frameQueue.setmSize(100);
            }
            FrameQueue frameQueue2 = this.mossAudioFrameQueue;
            if (frameQueue2 != null) {
                frameQueue2.setmSize(200);
            }
        }
        this.maxlen = HiSystemValue.Max_getbufsize(this.videowidth);
        return HiH264GetInfoOSSExt;
    }

    private int Playlocal_CloseH264() {
        return PlayLocalFile.HiH264DestroyReaderOSS(this.ossread_readhandle[0]);
    }

    private int Playlocal_OpenMp4(String str) {
        int[] iArr = new int[10];
        long[] jArr = this.mp4_readhandle;
        jArr[0] = 0;
        int HIEncMp4CreateReader2 = EncMp4.HIEncMp4CreateReader2(jArr, str, iArr);
        if (HIEncMp4CreateReader2 != 0) {
            HiLog.e("", 1, 1);
            return HIEncMp4CreateReader2;
        }
        HiLog.e("" + iArr[0] + ":::" + iArr[1] + ":::" + iArr[2] + ":::" + iArr[3] + ":::" + iArr[4] + ":::" + iArr[5], 1, 0);
        setplaylocal(iArr[0], iArr[1], iArr[2] / 1000, 0L, iArr[4], 0);
        this.videowidth = iArr[0];
        this.videoheight = iArr[1];
        this.filetime = iArr[2];
        int i = iArr[3] == 5 ? 5 : 4;
        this.videotype = i;
        if (5 == i && Build.VERSION.SDK_INT >= 23) {
            this.isH265DevDec = true;
        }
        this.mossVideoFrameQueue = new FrameQueue();
        this.mossAudioFrameQueue = new FrameQueue();
        this.maxlen = HiSystemValue.Max_getbufsize(this.videowidth);
        return HIEncMp4CreateReader2;
    }

    private int Playlocal_CloseMp4() {
        return EncMp4.HIEncMp4DestroyReader2(this.mp4_readhandle[0]);
    }

    public int PlayLocal_Seek(int i, boolean z) {
        HiLog.e("::::" + i, 1, 0);
        if (this.isSeekend != z) {
            FrameQueue frameQueue = this.mossAudioFrameQueue;
            if (frameQueue != null) {
                frameQueue.removeAll();
            }
            FrameQueue frameQueue2 = this.mossVideoFrameQueue;
            if (frameQueue2 != null) {
                frameQueue2.removeAll();
            }
            this.isqueueenpty = true;
        }
        if (!this.isSeek) {
            this.isSeek = z;
        }
        this.isSeekend = z;
        this.SaveisSeek = true;
        this.SaveSeekTime = i;
        HiLog.e("PlayLocal_Seek:" + i + ":OSSLoadFin:" + this.OSSLoadFin + ":seeking:" + z, 1, 0);
        return 0;
    }

    public void PlayLocal_Speed(int i, int i2) {
        HiLog.e("" + i + ":::" + i2 + "::::" + this.savespeed + "::::" + this.subtime, 1, 0);
        int i3 = this.savespeed;
        if ((i3 == 0 && i > 2) || ((i3 > 0 && i == 0) || (i3 < 3 && i > 2))) {
            this.isSpeed = true;
            FrameQueue frameQueue = this.mossAudioFrameQueue;
            if (frameQueue != null) {
                frameQueue.removeAll();
            }
            FrameQueue frameQueue2 = this.mossVideoFrameQueue;
            if (frameQueue2 != null) {
                frameQueue2.removeAll();
            }
            PlayLocal_Seek(this.subtime, false);
        }
        if (i2 != 0) {
            this.saveInterval = i2;
        }
        this.savespeed = i;
    }

    public void PlayLocal_pause() {
        this.isPlaying = false;
    }

    public void PlayLocal_Resume() {
        this.isPlaying = true;
    }

    public void SetDecodeVideoType(int i) {
        this.DecodeVideoType = i;
    }

    public void SetDecodeViVoVideoType(int i) {
        this.DecodeViVoVideoType = i;
    }

    private void DecodeSleep(HiThread hiThread, int i) {
        switch (this.savespeed) {
            case 3:
                int i2 = this.saveInterval;
                if (i2 * 17 > i) {
                    hiThread.sleep((i2 * 17) - i);
                    return;
                }
                return;
            case 4:
                int i3 = this.saveInterval;
                if (i3 * 16 > i) {
                    hiThread.sleep((i3 * 16) - i);
                    return;
                }
                return;
            case 5:
                int i4 = this.saveInterval;
                if (i4 * 15 > i) {
                    hiThread.sleep((i4 * 15) - i);
                    return;
                }
                return;
            case 6:
                int i5 = this.saveInterval;
                if (i5 * 14 > i) {
                    hiThread.sleep((i5 * 14) - i);
                    return;
                }
                return;
            case 7:
                int i6 = this.saveInterval;
                if (i6 * 13 > i) {
                    hiThread.sleep((i6 * 13) - i);
                    return;
                }
                return;
            case 8:
                int i7 = this.saveInterval;
                if (i7 * 12 > i) {
                    hiThread.sleep((i7 * 12) - i);
                    return;
                }
                return;
            case 9:
                int i8 = this.saveInterval;
                if (i8 * 11 > i) {
                    hiThread.sleep((i8 * 11) - i);
                    return;
                }
                return;
            case 10:
                int i9 = this.saveInterval;
                if (i9 * 10 > i) {
                    hiThread.sleep((i9 * 10) - i);
                    return;
                }
                return;
            case 11:
                int i10 = this.saveInterval;
                if (i10 * 9 > i) {
                    hiThread.sleep((i10 * 9) - i);
                    return;
                }
                return;
            case 12:
                int i11 = this.saveInterval;
                if (i11 * 8 > i) {
                    hiThread.sleep((i11 * 8) - i);
                    return;
                }
                return;
            case 13:
                int i12 = this.saveInterval;
                if (i12 * 7 > i) {
                    hiThread.sleep((i12 * 7) - i);
                    return;
                }
                return;
            case 14:
                int i13 = this.saveInterval;
                if (i13 * 6 > i) {
                    hiThread.sleep((i13 * 6) - i);
                    return;
                }
                return;
            case 15:
                int i14 = this.saveInterval;
                if (i14 * 5 > i) {
                    hiThread.sleep((i14 * 5) - i);
                    return;
                }
                return;
            case 16:
                int i15 = this.saveInterval;
                if (i15 * 4 > i) {
                    hiThread.sleep((i15 * 4) - i);
                    return;
                }
                return;
            case 17:
                int i16 = this.saveInterval;
                if (i16 * 3 > i) {
                    hiThread.sleep((i16 * 3) - i);
                    return;
                }
                return;
            case 18:
                break;
            case 19:
                int i17 = this.saveInterval;
                if (i17 > i) {
                    hiThread.sleep(i17 - i);
                    break;
                }
                break;
            case 20:
                return;
            default:
                hiThread.sleep(50);
                return;
        }
        int i18 = this.saveInterval;
        if (i18 * 2 > i) {
            hiThread.sleep((i18 * 2) - i);
        }
    }

    private void save2Queue(byte[] bArr, byte[] bArr2, int i, int i2, int i3, int i4, int i5, int i6, Boolean bool) {
        byte[] parseContent = HiChipDefines.HI_P2P_S_AVFrame.parseContent(i3, i, i4, i5);
        System.arraycopy(parseContent, 0, bArr, 0, parseContent.length);
        System.arraycopy(bArr2, 0, bArr, parseContent.length, i);
        FrameData frameData = new FrameData(bArr, parseContent.length + i);
        HiLog.e("" + i + ":::" + i2 + ":::" + i3 + ":::" + i4 + ":::" + i5 + ":::" + bool + ":::" + this.isSeek + ":::" + this.isSpeed);
        if (i2 == 1 || i2 == 1180063816) {
            if (this.mossVideoFrameQueue != null && bool.booleanValue() && this.isPlaying) {
                boolean z = this.isSeek;
                if (!z && !this.isSpeed) {
                    this.mossVideoFrameQueue.addLast(frameData);
                    return;
                }
                if (z) {
                    if (i5 == 1) {
                        this.mossVideoFrameQueue.addLast(frameData);
                        this.isSeek = false;
                        return;
                    }
                    return;
                }
                if (i5 == 1 || (this.isH265DevDec && i6 < 3)) {
                    this.isSpeed = false;
                    this.mossVideoFrameQueue.addLast(frameData);
                    return;
                }
                return;
            }
            return;
        }
        if (!this.isSeek && this.savespeed == 0 && this.mossAudioFrameQueue != null && bool.booleanValue() && this.isPlaying) {
            this.mossAudioFrameQueue.addLast(frameData);
        }
    }

    public class ThreadPlayLocal extends HiThread {
        private ThreadPlayLocal() {
        }

        @Override
        public void run() {
            if (HiPlayOSSSDK.this.video_type != HiPlayOSSSDK.this.VIDEO_TYPE_AVI) {
                if (HiPlayOSSSDK.this.video_type != HiPlayOSSSDK.this.VIDEO_TYPE_MP4) {
                    if (HiPlayOSSSDK.this.video_type == HiPlayOSSSDK.this.VIDEO_TYPE_H264) {
                        if (!HiPlayOSSSDK.this.isOSSFile) {
                            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
                            hiPlayOSSSDK.DoRead264File(hiPlayOSSSDK.threadPlayLocal);
                        } else {
                            HiPlayOSSSDK hiPlayOSSSDK2 = HiPlayOSSSDK.this;
                            hiPlayOSSSDK2.DoReadOSS264File(hiPlayOSSSDK2.threadPlayLocal);
                        }
                    }
                } else {
                    HiPlayOSSSDK hiPlayOSSSDK3 = HiPlayOSSSDK.this;
                    hiPlayOSSSDK3.DoReadMp4File(hiPlayOSSSDK3.threadPlayLocal);
                }
            } else {
                HiPlayOSSSDK hiPlayOSSSDK4 = HiPlayOSSSDK.this;
                hiPlayOSSSDK4.DoReadAVIFile(hiPlayOSSSDK4.threadPlayLocal);
            }
            HiLog.e("======== ThreadPlayLocal  end ========", 1, 0);
        }
    }

    public class ThreadDecodeVideo extends HiThread {
        private ThreadDecodeVideo() {
        }
    }

    public class ThreadDecodeAudio extends HiThread {
        private ThreadDecodeAudio() {
        }
    }

    private void startPlaybackThread() {
        this.isDisplayFrist = false;
        FrameQueue frameQueue = this.mossVideoFrameQueue;
        if (frameQueue != null) {
            frameQueue.setmSize(100);
        }
        FrameQueue frameQueue2 = this.mossAudioFrameQueue;
        if (frameQueue2 != null) {
            frameQueue2.setmSize(200);
        }
        ThreadDecodeAudioCloud threadDecodeAudioCloud = this.mThreadDecodeAudioCloud;
        if (threadDecodeAudioCloud == null) {
            ThreadDecodeAudioCloud threadDecodeAudioCloud2 = new ThreadDecodeAudioCloud();
            this.mThreadDecodeAudioCloud = threadDecodeAudioCloud2;
            threadDecodeAudioCloud2.startThread();
        } else {
            threadDecodeAudioCloud.isRunning = true;
            DoDecodeAudio(this.mThreadDecodeAudioCloud);
        }
        ThreadDecodeVideoCloud threadDecodeVideoCloud = this.mThreadDecodeVideoCloud;
        if (threadDecodeVideoCloud == null) {
            ThreadDecodeVideoCloud threadDecodeVideoCloud2 = new ThreadDecodeVideoCloud();
            this.mThreadDecodeVideoCloud = threadDecodeVideoCloud2;
            threadDecodeVideoCloud2.startThread();
        } else {
            threadDecodeVideoCloud.isRunning = true;
            DoDecodeVideo(this.mThreadDecodeVideoCloud);
        }
    }

    private void stopPlaybackThread() {
        HiLog.e("stopPlaybackThread", 1, 0);
        ThreadDecodeVideoCloud threadDecodeVideoCloud = this.mThreadDecodeVideoCloud;
        if (threadDecodeVideoCloud != null) {
            threadDecodeVideoCloud.weakup();
            this.mThreadDecodeVideoCloud.stopThread();
        }
        ThreadDecodeAudioCloud threadDecodeAudioCloud = this.mThreadDecodeAudioCloud;
        if (threadDecodeAudioCloud != null) {
            threadDecodeAudioCloud.weakup();
            this.mThreadDecodeAudioCloud.stopThread();
        }
        this.mThreadDecodeVideoCloud = null;
        this.mThreadDecodeAudioCloud = null;
        HiLog.e("stopPlaybackThread", 1, 0);
    }

    private int JudgmentSeek(int i) {
        HiLog.e("JudgmentSeek:" + i, 1, 0);
        Oss2FileQueue oss2FileQueue = this.mOssFrameQueue;
        if (oss2FileQueue != null && oss2FileQueue.getCount() > 0) {
            Oss2File Findindexdata = this.mOssFrameQueue.Findindexdata(i, 0);
            if (Findindexdata != null) {
                if (Findindexdata.head.u32Start <= i && Findindexdata.head.u32End > i) {
                    this.mOssFrameQueue.removeindexdata(Findindexdata);
                    this.mOssFrameQueue.addLast(new Oss2File(HiChipDefines.HI_Oss_DownLoad2File.parseContent(Findindexdata.head.u32Start, i)));
                } else if (Findindexdata.head.u32Start > i) {
                    i = Findindexdata.head.u32Start;
                }
                return i;
            }
            i = -1;
            return i;
        }
        int i2 = this.SaveOssLoad;
        if (i <= i2) {
            return -1;
        }
        this.mOssFrameQueue.addLast(new Oss2File(HiChipDefines.HI_Oss_DownLoad2File.parseContent(i2, i)));
        return -1;
    }

    public class ThreadOSSDownFileTime extends HiThread {
        long Firtime;
        byte[] bufferrecdb;
        int len;
        int msgwhat;
        int needlen;
        int readlen;
        long savetime;

        private ThreadOSSDownFileTime() {
            this.needlen = 10240;
            this.bufferrecdb = new byte[10240];
            this.len = 0;
            this.readlen = 0;
            this.Firtime = System.currentTimeMillis();
            this.msgwhat = 24832;
        }

        public void SetNeedLen(int i) {
            this.needlen = i;
            this.bufferrecdb = new byte[i];
        }

        @Override
        public void run() {
            InputStream OSSDownsync = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, 0, 0, HiPlayOSSSDK.this.handler, this.msgwhat);
            if (OSSDownsync != null) {
                while (this.isRunning) {
                    try {
                        int read = OSSDownsync.read(this.bufferrecdb);
                        this.len = read;
                        if (read != -1) {
                            while (HiPlayOSSSDK.this.mstartrecvdata != this.msgwhat - 1 && this.isRunning) {
                                sleep(10);
                            }
                            HiLog.e(this.readlen + ":::" + this.needlen + ";;;;;" + this.len + "::" + this.Firtime + "::::" + this.savetime, 1, 0);
                            HiPlayOSSSDK.this.setOSSData(this.msgwhat + 5, this.bufferrecdb, this.len, 0, 0, 0, 0, 1);
                        } else {
                            HiLog.e("" + this.readlen, 1, 0);
                            HiPlayOSSSDK.this.setOSSData(this.msgwhat + 5, this.bufferrecdb, this.len, 0, 0, 0, 0, 2);
                            this.isRunning = false;
                            return;
                        }
                    } catch (IOException e) {
                        HiLog.e("", 1, 1);
                        e.printStackTrace();
                        Message obtain = Message.obtain();
                        obtain.obj = e;
                        obtain.what = this.msgwhat + 2;
                        HiPlayOSSSDK.this.handler.sendMessage(obtain);
                        return;
                    }
                }
                return;
            }
            HiLog.e("", 1, 1);
            Message obtain2 = Message.obtain();
            obtain2.what = this.msgwhat + 3;
            HiPlayOSSSDK.this.handler.sendMessage(obtain2);
        }
    }

    public class ThreadOSSDownFileList extends HiThread {
        long Firtime;
        byte[] bufferrecdb;
        int len;
        int msgwhat;
        int needlen;
        int readlen;
        long savetime;

        private ThreadOSSDownFileList() {
            this.needlen = 10240;
            this.bufferrecdb = new byte[10240];
            this.len = 0;
            this.readlen = 0;
            this.Firtime = System.currentTimeMillis();
            this.msgwhat = 25088;
        }

        public void SetNeedLen(int i) {
            this.needlen = i;
            this.bufferrecdb = new byte[i];
        }

        @Override
        public void run() {
            InputStream OSSDownsync = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, 0, 0, HiPlayOSSSDK.this.handler, this.msgwhat);
            if (OSSDownsync != null) {
                while (true) {
                    try {
                        if (!this.isRunning) {
                            break;
                        }
                        int read = OSSDownsync.read(this.bufferrecdb);
                        this.len = read;
                        if (read != -1) {
                            while (HiPlayOSSSDK.this.mstartrecvdata != this.msgwhat - 1 && this.isRunning) {
                                sleep(10);
                            }
                            HiPlayOSSSDK.this.setOSSData(this.msgwhat + 5, this.bufferrecdb, this.len, 0, 0, 0, 0, 1);
                            HiLog.e(this.readlen + ":::" + this.needlen + ";;;;;" + this.len + "::" + this.Firtime + "::::" + this.savetime, 1, 0);
                        } else {
                            HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop, 1, 0);
                            HiPlayOSSSDK.this.setOSSData(this.msgwhat + 5, this.bufferrecdb, this.len, 0, 0, 0, 0, 2);
                            this.isRunning = false;
                            break;
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop + "::" + this.isRunning + ":::" + e.getMessage(), 1, 1);
                        Message obtain = Message.obtain();
                        obtain.obj = e;
                        obtain.what = this.msgwhat + 2;
                        HiPlayOSSSDK.this.handler.sendMessage(obtain);
                        return;
                    }
                }
                HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop + "::" + this.isRunning, 1, 0);
                return;
            }
            HiLog.e("", 1, 1);
            Message obtain2 = Message.obtain();
            obtain2.what = this.msgwhat + 3;
            HiPlayOSSSDK.this.handler.sendMessage(obtain2);
        }
    }

    public class ThreadOSSDown extends HiThread {
        long Firtime;
        byte[] buf;
        byte[] bufferhxend;
        byte[] bufferhxhead;
        int len;
        int msgwhat;
        int needlen;
        int readlen;
        int ret;
        long savetime;
        int seek;

        private ThreadOSSDown() {
            this.len = 0;
            this.readlen = 0;
            this.seek = 0;
            this.needlen = 20;
            this.bufferhxend = new byte[10240];
            this.bufferhxhead = new byte[20];
            this.buf = new byte[20];
            this.Firtime = System.currentTimeMillis();
            this.savetime = 0L;
            this.msgwhat = 25344;
        }

        @Override
        public void run() {
            HiLog.e("======== ThreadOSSDown  st ========" + HiPlayOSSSDK.this.localfilepathoss + "dddd" + HiPlayOSSSDK.this.mOssThreadExit, 1, 0);
            HiPlayOSSSDK.this.mOssThreadExit = true;
            HiPlayOSSSDK.this.osswrite_readhandle[0] = 0;
            this.ret = PlayLocalFile.HiH264CreateWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle, HiPlayOSSSDK.this.localfilepathoss);
            HiLog.e("HiH264CreateWriteOSS" + this.ret, 1, 0);
            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
            hiPlayOSSSDK.setOSSDownLoad(0, hiPlayOSSSDK.saveOssLoadLen, HiPlayOSSSDK.this.mOssFilesize);
            InputStream OSSDownsync = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, 0, this.needlen + (-1), HiPlayOSSSDK.this.handler, this.msgwhat);
            if (OSSDownsync != null) {
                while (true) {
                    try {
                        if (!this.isRunning) {
                            break;
                        }
                        int read = OSSDownsync.read(this.bufferhxhead);
                        this.len = read;
                        if (read == -1) {
                            break;
                        }
                        int i = this.readlen;
                        int i2 = i + read;
                        int i3 = this.needlen;
                        if (i2 <= i3) {
                            System.arraycopy(this.bufferhxhead, 0, this.buf, i, read);
                            this.readlen += this.len;
                        } else {
                            System.arraycopy(this.bufferhxhead, 0, this.buf, i, i3 - i);
                            HiPlayOSSSDK.this.parserecdata(this.buf, 2);
                            byte[] bArr = this.bufferhxhead;
                            int i4 = this.needlen;
                            int i5 = this.readlen;
                            System.arraycopy(bArr, i4 - i5, this.buf, 0, this.len - (i4 - i5));
                            this.readlen = this.len - (this.needlen - this.readlen);
                        }
                        if (this.readlen == this.needlen) {
                            HiPlayOSSSDK.this.parserecdata(this.buf, 2);
                            this.readlen = 0;
                        }
                    } catch (IOException e) {
                        HiLog.e("", 1, 1);
                        e.printStackTrace();
                        Message obtain = Message.obtain();
                        obtain.obj = e;
                        obtain.what = this.msgwhat + 2;
                        HiPlayOSSSDK.this.handler.sendMessage(obtain);
                        PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
                        return;
                    }
                }
                this.seek = (HiPlayOSSSDK.this.mOssFilesize - 12288) - 16;
                HiLog.e("" + this.seek + "::" + HiPlayOSSSDK.this.mOssFilesize, 1, 0);
                HiPlayOSSSDK hiPlayOSSSDK2 = HiPlayOSSSDK.this;
                hiPlayOSSSDK2.saveOssLoadLen = hiPlayOSSSDK2.saveOssLoadLen + 20;
                this.msgwhat = 25600;
                this.Firtime = System.currentTimeMillis();
                InputStream OSSDownsync2 = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, HiPlayOSSSDK.this.mOssFilesize + (-12288) + (-16), HiPlayOSSSDK.this.mOssFilesize + (-1), HiPlayOSSSDK.this.handler, this.msgwhat);
                if (OSSDownsync2 != null) {
                    while (true) {
                        try {
                            if (!this.isRunning) {
                                break;
                            }
                            int read2 = OSSDownsync2.read(this.bufferhxend);
                            this.len = read2;
                            if (read2 == -1) {
                                break;
                            }
                            int HiH264WriteOSS = PlayLocalFile.HiH264WriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0], this.bufferhxend, this.len, this.seek);
                            this.ret = HiH264WriteOSS;
                            if (HiH264WriteOSS != 0) {
                                HiLog.e("HiH264WriteOSS  error ", 1, 1);
                            }
                            if (this.seek != 0) {
                                this.seek = 0;
                            }
                            HiPlayOSSSDK.this.saveOssLoadLen += this.len;
                            HiPlayOSSSDK hiPlayOSSSDK3 = HiPlayOSSSDK.this;
                            hiPlayOSSSDK3.setOSSDownLoad(1, hiPlayOSSSDK3.saveOssLoadLen, HiPlayOSSSDK.this.mOssFilesize);
                        } catch (IOException e2) {
                            HiLog.e("", 1, 1);
                            e2.printStackTrace();
                            Message obtain2 = Message.obtain();
                            obtain2.obj = e2;
                            obtain2.what = this.msgwhat + 2;
                            HiPlayOSSSDK.this.handler.sendMessage(obtain2);
                            PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
                            return;
                        }
                    }
                    if (HiPlayOSSSDK.this.saveOssLoadLen == 12324) {
                        HiPlayOSSSDK.this.isOssreadHead_end = true;
                    }
                    HiLog.e("下载头尾" + HiPlayOSSSDK.this.mOssFilesize + "::" + HiPlayOSSSDK.this.mOssLoadEn, 1, 0);
                    if (HiPlayOSSSDK.this.isOssreadHead_end) {
                        HiPlayOSSSDK.this.saveOssLoadLen = 12324;
                        HiPlayOSSSDK.this.mOssLoadEn = ((r0.mOssFilesize - 12288) - 16) - 1;
                        HiPlayOSSSDK.this.mOssLoadSt = 20;
                        HiPlayOSSSDK.this.setOSSData(4, new byte[1], 1, 1, 1, 1, 1, 1);
                    }
                    this.seek = 20;
                    HiPlayOSSSDK hiPlayOSSSDK4 = HiPlayOSSSDK.this;
                    hiPlayOSSSDK4.SaveOssLoad = hiPlayOSSSDK4.mOssLoadSt;
                    this.msgwhat = 25856;
                    this.Firtime = System.currentTimeMillis();
                    InputStream OSSDownsync3 = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, HiPlayOSSSDK.this.mOssLoadSt, HiPlayOSSSDK.this.mOssLoadEn, HiPlayOSSSDK.this.handler, this.msgwhat);
                    if (OSSDownsync3 != null) {
                        while (true) {
                            try {
                                if (!this.isRunning) {
                                    break;
                                }
                                int read3 = OSSDownsync3.read(this.bufferhxend);
                                this.len = read3;
                                if (read3 == -1) {
                                    break;
                                }
                                int HiH264WriteOSS2 = PlayLocalFile.HiH264WriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0], this.bufferhxend, this.len, this.seek);
                                this.ret = HiH264WriteOSS2;
                                if (HiH264WriteOSS2 != 0) {
                                    HiLog.e("HiH264WriteOSS  error ", 1, 1);
                                }
                                if (this.seek != 0) {
                                    this.seek = 0;
                                }
                                HiPlayOSSSDK.this.SaveOssLoad += this.len;
                                HiPlayOSSSDK.this.saveOssLoadLen += this.len;
                                HiPlayOSSSDK.this.mOssLoadSt += this.len;
                                HiPlayOSSSDK hiPlayOSSSDK5 = HiPlayOSSSDK.this;
                                hiPlayOSSSDK5.setOSSDownLoad(1, hiPlayOSSSDK5.saveOssLoadLen, HiPlayOSSSDK.this.mOssFilesize);
                            } catch (IOException e3) {
                                HiLog.e("", 1, 1);
                                e3.printStackTrace();
                                Message obtain3 = Message.obtain();
                                obtain3.obj = e3;
                                obtain3.what = this.msgwhat + 2;
                                HiPlayOSSSDK.this.handler.sendMessage(obtain3);
                                PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
                                return;
                            }
                        }
                    } else {
                        HiLog.e("", 1, 1);
                        Message obtain4 = Message.obtain();
                        obtain4.what = this.msgwhat + 3;
                        HiPlayOSSSDK.this.handler.sendMessage(obtain4);
                        HiPlayOSSSDK.this.mOssThreadExit = false;
                    }
                    if (HiPlayOSSSDK.this.saveOssLoadLen == HiPlayOSSSDK.this.mOssFilesize) {
                        HiPlayOSSSDK.this.OSSLoadFin = true;
                        HiPlayOSSSDK hiPlayOSSSDK6 = HiPlayOSSSDK.this;
                        hiPlayOSSSDK6.setOSSDownLoad(2, hiPlayOSSSDK6.saveOssLoadLen, HiPlayOSSSDK.this.mOssFilesize);
                    } else {
                        HiLog.e("saveOssLoadLen:" + HiPlayOSSSDK.this.saveOssLoadLen + ":mOssFilesize:" + HiPlayOSSSDK.this.mOssFilesize + "mOssThreadExit:" + HiPlayOSSSDK.this.mOssThreadExit, 1, 1);
                        if (HiPlayOSSSDK.this.mOssThreadExit) {
                            HiPlayOSSSDK hiPlayOSSSDK7 = HiPlayOSSSDK.this;
                            hiPlayOSSSDK7.setOSSDownLoad(4, hiPlayOSSSDK7.saveOssLoadLen, HiPlayOSSSDK.this.mOssFilesize);
                        }
                    }
                    PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
                    HiPlayOSSSDK.this.mOssThreadExit = false;
                    HiLog.e("======== ThreadOSSDown  end ========" + HiPlayOSSSDK.this.localfilepathoss, 1, 0);
                    return;
                }
                HiLog.e("", 1, 1);
                Message obtain5 = Message.obtain();
                obtain5.what = this.msgwhat + 3;
                HiPlayOSSSDK.this.handler.sendMessage(obtain5);
                PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
                HiPlayOSSSDK.this.mOssThreadExit = false;
                return;
            }
            HiLog.e("", 1, 1);
            Message obtain6 = Message.obtain();
            obtain6.what = this.msgwhat + 3;
            HiPlayOSSSDK.this.handler.sendMessage(obtain6);
            PlayLocalFile.HiH264DestroyWriteOSS(HiPlayOSSSDK.this.osswrite_readhandle[0]);
            HiPlayOSSSDK.this.mOssThreadExit = false;
        }
    }

    public class ThreadManageOSS extends HiThread {
        private ThreadManageOSS() {
        }

        @Override
        public void run() {
            while (HiPlayOSSSDK.this.mOssThreadExit) {
                sleep(100);
                HiLog.e("::::" + HiPlayOSSSDK.this.mOssThreadExit, 1, 1);
            }
            HiLog.e("::::" + HiPlayOSSSDK.this.mOssThreadExit, 1, 0);
            HiPlayOSSSDK.this.isOSSFile = true;
            HiPlayOSSSDK.this.SaveOssLoad = 0;
            HiPlayOSSSDK.this.OSSLoadFin = false;
            HiPlayOSSSDK.this.isPlayossEnd = false;
            HiPlayOSSSDK.this.isOssreadHead_end = false;
            HiPlayOSSSDK.this.saveOssLoadLen = 0;
            HiPlayOSSSDK.this.mOssLoadEn = 0;
            HiPlayOSSSDK.this.mOssLoadSt = 0;
            HiPlayOSSSDK.this.isLoading_FLAG = false;
            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
            hiPlayOSSSDK.video_type = hiPlayOSSSDK.VIDEO_TYPE_H264;
            if (HiPlayOSSSDK.this.mhiConfig != null) {
                long currentTimeMillis = System.currentTimeMillis() - HiPlayOSSSDK.this.mSaveOssGetTime;
                HiLog.e("" + System.currentTimeMillis() + ":::" + HiPlayOSSSDK.this.mSaveOssGetTime + ":::::" + currentTimeMillis + ":::" + HiPlayOSSSDK.this.mSetOsstime + "::::" + (((HiPlayOSSSDK.this.mosstokentime * 60) * 1000) - HiPlayOSSSDK.this.mSetOsstime), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_objectKey(), 1, 0);
                if (currentTimeMillis > ((HiPlayOSSSDK.this.mosstokentime * 60) * 1000) - HiPlayOSSSDK.this.mSetOsstime) {
                    if (HiPlayOSSSDK.this.mIsOCloud) {
                        if (HiPlayOSSSDK.this.mUidEXIPREtimer != null) {
                            HiPlayOSSSDK.this.mUidEXIPREtimer.cancel();
                        }
                        HiPlayOSSSDK.this.mUidEXIPREtimer = null;
                        HiCloudSDK hiCloudSDK = HiPlayOSSSDK.this.mhiCloudsdk;
                        HiPlayOSSSDK hiPlayOSSSDK2 = HiPlayOSSSDK.this;
                        hiCloudSDK.HiCloudSDKgetOCloudinfo(hiPlayOSSSDK2, 0, hiPlayOSSSDK2.mhiConfig.getOSS_UUID(), HiPlayOSSSDK.this.mhiCloudname, HiPlayOSSSDK.this.mhiCloudpwd, HiPlayOSSSDK.this.mhiCloudKey, HiPlayOSSSDK.this.mhiCloudSer, HiPlayOSSSDK.this.mhiCloudport, (short) 5);
                    } else {
                        HiCloudSDK hiCloudSDK2 = HiPlayOSSSDK.this.mhiCloudsdk;
                        HiPlayOSSSDK hiPlayOSSSDK3 = HiPlayOSSSDK.this;
                        hiCloudSDK2.HiCloudSDKgetCloudinfo(hiPlayOSSSDK3, 0, hiPlayOSSSDK3.mhiConfig.getOSS_UUID(), HiPlayOSSSDK.this.mhiCloudname, HiPlayOSSSDK.this.mhiCloudpwd, HiPlayOSSSDK.this.mhiCloudKey, HiPlayOSSSDK.this.mhiCloudSer, HiPlayOSSSDK.this.mhiCloudport, (short) 5);
                    }
                    HiPlayOSSSDK.this.mOssOperation = 3;
                    return;
                }
                if (HiPlayOSSSDK.this.mthreadOSSDowndata != null) {
                    HiPlayOSSSDK.this.mthreadOSSDowndata.weakup();
                    HiPlayOSSSDK.this.mthreadOSSDowndata.stopThread();
                    HiPlayOSSSDK.this.mthreadOSSDowndata = null;
                }
                if (HiPlayOSSSDK.this.mthreadOSSDowndata == null) {
                    HiPlayOSSSDK.this.mthreadOSSDowndata = new ThreadOSSDown();
                    HiPlayOSSSDK.this.mthreadOSSDowndata.startThread();
                }
            }
        }
    }

    public class ThreadOSSDownCustom extends HiThread {
        long Firtime;
        byte[] bufferrecdb;
        int len;
        int msgwhat;
        int needlen;
        int readlen;
        long savetime;

        private ThreadOSSDownCustom() {
            this.needlen = 2048;
            this.bufferrecdb = new byte[2048];
            this.len = 0;
            this.readlen = 0;
            this.Firtime = System.currentTimeMillis();
            this.msgwhat = 26112;
        }

        public void SetNeedLen(int i) {
            this.needlen = i;
            this.bufferrecdb = new byte[i];
        }

        @Override
        public void run() {
            InputStream OSSDownsync = HiPlayOSSSDK.this.mhiCloud.OSSDownsync(HiPlayOSSSDK.this.mhiConfig, 0, 0, HiPlayOSSSDK.this.handler, this.msgwhat);
            if (OSSDownsync != null) {
                while (true) {
                    try {
                        if (!this.isRunning) {
                            break;
                        }
                        int read = OSSDownsync.read(this.bufferrecdb);
                        this.len = read;
                        if (read != -1) {
                            HiLog.e(this.readlen + ":::" + this.needlen + ";;;;;" + this.len + "::" + this.Firtime + ":::" + this.savetime, 1, 0);
                            HiPlayOSSSDK.this.setOSSData(5, this.bufferrecdb, this.len, 0, 0, 0, 0, 1);
                        } else {
                            HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop, 1, 0);
                            HiPlayOSSSDK.this.setOSSData(5, this.bufferrecdb, this.len, 0, 0, 0, 0, 2);
                            this.isRunning = false;
                            break;
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop + "::" + this.isRunning + ":::" + e.getMessage(), 1, 1);
                        Message obtain = Message.obtain();
                        obtain.obj = e;
                        obtain.what = this.msgwhat + 2;
                        HiPlayOSSSDK.this.handler.sendMessage(obtain);
                        return;
                    }
                }
                HiLog.e("" + HiPlayOSSSDK.this.isPlayEnd + "::::" + HiPlayOSSSDK.this.isPlayossEnd + "::::" + HiPlayOSSSDK.this.isPlayStop + "::" + this.isRunning, 1, 0);
                return;
            }
            HiLog.e("", 1, 1);
            Message obtain2 = Message.obtain();
            obtain2.what = this.msgwhat + 3;
            HiPlayOSSSDK.this.handler.sendMessage(obtain2);
        }
    }

    public void DoReadOSS264File(HiThread hiThread) {
        int i;
        long j;
        int i2;
        byte[] bArr;
        long[] jArr;
        byte[] bArr2;
        long j2;
        long j3;
        int i3;
        int i4;
        int i5;
        byte[] bArr3;
        int i6;
        int i7;
        boolean z;
        int i8;
        boolean z2;
        int i9;
        byte[] bArr4;
        long[] jArr2;
        int i10;
        long j4;
        ?? r9;
        int i11;
        int i12;
        boolean z3;
        int i13;
        byte[] bArr5;
        long j5;
        int i14;
        byte[] bArr6;
        char c;
        int i15;
        int i16;
        boolean z4;
        int i17;
        long j6;
        int i18;
        int i19;
        int i20;
        boolean z5;
        byte[] bArr7;
        byte[] bArr8;
        boolean z6;
        int i21;
        int i22;
        int i23;
        FrameQueue frameQueue;
        FrameQueue frameQueue2;
        FrameQueue frameQueue3;
        boolean z7;
        boolean z8;
        boolean z9;
        int[] iArr = new int[16];
        long[] jArr3 = new long[4];
        byte[] MallocByte = Packet.MallocByte(16);
        byte[] MallocByte2 = Packet.MallocByte(this.maxlen);
        byte[] MallocByte3 = Packet.MallocByte(this.maxlen);
        byte[] MallocByte4 = Packet.MallocByte(this.maxlen);
        ?? r8 = 0;
        if (MallocByte2 == null || MallocByte3 == null || MallocByte4 == null) {
            hiThread.isRunning = false;
        }
        boolean z10 = true;
        HiLog.e("======== ThreadPlayLocal  start ========", 1, 0);
        int i24 = this.SaveOssLoad;
        boolean z11 = this.OSSLoadFin;
        long HiOCloudInit = this.mIsOCloud ? DoAes.HiOCloudInit(this.mOCloudUid, this.mOCloudDate) : 0L;
        HiLog.e("======== ThreadPlayLocal  start ========" + HiOCloudInit, 1, 0);
        long j7 = HiOCloudInit;
        int i25 = 0;
        int i26 = 0;
        int i27 = 0;
        boolean z12 = false;
        int i28 = 0;
        int i29 = 0;
        int i30 = 0;
        int i31 = 0;
        int i32 = 100;
        long j8 = 0;
        int i33 = 20;
        int i34 = 1180063816;
        int i35 = 200;
        while (true) {
            if (!hiThread.isRunning) {
                i = r8;
                j = j7;
                break;
            }
            if (!this.isPlaying || this.mossVideoFrameQueue == null) {
                bArr = MallocByte2;
                jArr = jArr3;
                bArr2 = MallocByte;
                j2 = j7;
                j3 = j8;
                i3 = r8;
                i4 = i25;
                i5 = i29;
                bArr3 = MallocByte3;
                i6 = 200;
            } else if (this.mossAudioFrameQueue == null) {
                bArr = MallocByte2;
                jArr = jArr3;
                bArr2 = MallocByte;
                j2 = j7;
                i6 = 200;
                j3 = j8;
                i3 = r8;
                i4 = i25;
                i5 = i29;
                bArr3 = MallocByte3;
            } else {
                boolean z13 = this.mOssDownEnd;
                if (z13) {
                    boolean z14 = z11;
                    i7 = i24;
                    z = z14;
                } else {
                    z = this.OSSLoadFin;
                    i7 = this.SaveOssLoad;
                }
                if (z) {
                    if (!z13) {
                        this.mOssDownEnd = z10;
                    }
                    if (i32 != 8) {
                        this.isLoading_FLAG = r8;
                        i35 = 50;
                        i8 = 8;
                        synchronized (this) {
                            if (this.SaveisSeek) {
                                if (z) {
                                    z2 = z;
                                    i9 = i8;
                                    bArr4 = MallocByte3;
                                    jArr2 = jArr3;
                                    j = j7;
                                    i10 = i7;
                                    j4 = j8;
                                    z7 = z10;
                                    int i36 = -1;
                                    int i37 = 0;
                                    while (i36 != 0 && i37 < 100) {
                                        i36 = PlayLocalFile.HiH264SeekOSS(this.ossread_readhandle[0], this.SaveSeekTime);
                                        HiLog.e("PlayLocalFile.HiH264SeekOSS    :" + this.SaveSeekTime + "dddddd" + i36 + ":::" + i37, z7 ? 1 : 0, 0);
                                        if (i36 == 0) {
                                            FrameQueue frameQueue4 = this.mossAudioFrameQueue;
                                            if (frameQueue4 != null) {
                                                frameQueue4.removeAll();
                                            }
                                            FrameQueue frameQueue5 = this.mossVideoFrameQueue;
                                            if (frameQueue5 != null) {
                                                frameQueue5.removeAll();
                                            }
                                            this.SaveisSeek = false;
                                        } else {
                                            i37++;
                                            HiLog.e("PlayLocalFile.HiH264SeekOSS  error  :" + i36 + ":::" + i37, z7 ? 1 : 0, 0);
                                        }
                                    }
                                } else {
                                    long[] jArr4 = jArr3;
                                    int HiH264FindIFrameOSS = PlayLocalFile.HiH264FindIFrameOSS(this.ossread_readhandle[r8], this.SaveSeekTime, jArr4);
                                    StringBuilder sb = new StringBuilder();
                                    sb.append(this.SaveSeekTime);
                                    sb.append("::");
                                    sb.append(HiH264FindIFrameOSS);
                                    sb.append("::");
                                    boolean z15 = z;
                                    i10 = i7;
                                    sb.append(jArr4[r8]);
                                    sb.append("::::");
                                    bArr4 = MallocByte3;
                                    sb.append(jArr4[1]);
                                    sb.append(":::");
                                    sb.append(jArr4[2]);
                                    sb.append("::::::");
                                    sb.append(j8);
                                    sb.append(":::");
                                    sb.append(this.u32AVFramePTS1);
                                    HiLog.e(sb.toString(), 1, 0);
                                    if (HiH264FindIFrameOSS == 0) {
                                        long j9 = jArr4[0];
                                        long j10 = jArr4[2];
                                        StringBuilder sb2 = new StringBuilder();
                                        sb2.append("播放缓冲中没有   清空播放缓冲   需处理oss:::");
                                        FrameQueue frameQueue6 = this.mossVideoFrameQueue;
                                        sb2.append(frameQueue6 != null ? frameQueue6.getCount() : -1);
                                        sb2.append("::");
                                        FrameQueue frameQueue7 = this.mossAudioFrameQueue;
                                        sb2.append(frameQueue7 != null ? frameQueue7.getCountDataNew() : -1);
                                        HiLog.e(sb2.toString(), 1, 0);
                                        z2 = z15;
                                        i9 = i8;
                                        j = j7;
                                        j4 = j8;
                                        jArr2 = jArr4;
                                        z7 = true;
                                        setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, 21);
                                        int i38 = (int) j9;
                                        this.saveframeseekpos = i38;
                                        this.isExitOSSLoad = true;
                                        i27 = PlayLocalFile.HiH264SeekOSS(this.ossread_readhandle[0], this.SaveSeekTime);
                                        this.SaveisSeek = false;
                                        FrameQueue frameQueue8 = this.mossAudioFrameQueue;
                                        if (frameQueue8 != null) {
                                            frameQueue8.removeAll();
                                        }
                                        FrameQueue frameQueue9 = this.mossVideoFrameQueue;
                                        if (frameQueue9 != null) {
                                            frameQueue9.removeAll();
                                        }
                                        StringBuilder sb3 = new StringBuilder();
                                        sb3.append("播放缓冲中没有   清空播放缓冲   需处理oss:::");
                                        FrameQueue frameQueue10 = this.mossAudioFrameQueue;
                                        sb3.append(frameQueue10 != null ? frameQueue10.getCount() : -1);
                                        sb3.append("::");
                                        FrameQueue frameQueue11 = this.mossVideoFrameQueue;
                                        sb3.append(frameQueue11 != null ? frameQueue11.getCountDataNew() : -1);
                                        HiLog.e(sb3.toString(), 1, 0);
                                        i33 = i38;
                                    } else {
                                        i9 = i8;
                                        jArr2 = jArr4;
                                        j = j7;
                                        z2 = z15;
                                        z8 = true;
                                        j4 = j8;
                                        i27 = HiH264FindIFrameOSS;
                                        z9 = false;
                                        this.SaveisSeek = z9;
                                        r9 = z8;
                                    }
                                }
                                z9 = false;
                                z8 = z7;
                                this.SaveisSeek = z9;
                                r9 = z8;
                            } else {
                                z2 = z;
                                i9 = i8;
                                bArr4 = MallocByte3;
                                jArr2 = jArr3;
                                j = j7;
                                i10 = i7;
                                j4 = j8;
                                r9 = z10;
                            }
                            i11 = i33;
                            i12 = i27;
                        }
                        if (z2 || i10 > i11 + 16 + 10240) {
                            int HiH264ReadFrameOSSHead = PlayLocalFile.HiH264ReadFrameOSSHead(this.ossread_readhandle[0], MallocByte);
                            int byteArrayToInt_Little = Packet.byteArrayToInt_Little(MallocByte, 0);
                            int byteArrayToInt_Little2 = Packet.byteArrayToInt_Little(MallocByte, 4);
                            j8 = Packet.readUnsignedInt(MallocByte, 8);
                            HiLog.e(HiH264ReadFrameOSSHead + "::" + byteArrayToInt_Little2 + ":::" + Integer.toHexString(byteArrayToInt_Little) + "::" + j8, r9, 0);
                            if (byteArrayToInt_Little2 != 0 || z12) {
                                z12 = r9;
                            } else {
                                int i39 = i28 + 1;
                                if (i39 > 2) {
                                    Playlocal_CloseH264();
                                    hiThread.sleep(100);
                                    Playlocal_OpenH264(this.mSaveFilepath);
                                    hiThread.sleep(100);
                                    i33 = i11;
                                    i27 = HiH264ReadFrameOSSHead;
                                    i25 = byteArrayToInt_Little2;
                                    i26 = byteArrayToInt_Little;
                                    z10 = r9;
                                    z11 = z2;
                                    i24 = i10;
                                    jArr3 = jArr2;
                                    MallocByte3 = bArr4;
                                    i32 = i9;
                                    j7 = j;
                                    r8 = 0;
                                    i28 = 0;
                                } else {
                                    i28 = i39;
                                    z12 = z12;
                                }
                            }
                            if (HiH264ReadFrameOSSHead == 0) {
                                int i40 = i11 + 16;
                                if (byteArrayToInt_Little != 1229346888) {
                                    if (byteArrayToInt_Little2 > 0) {
                                        if (byteArrayToInt_Little2 <= 0) {
                                            this.isPlayEnd = true;
                                            break;
                                        }
                                        while (hiThread.isRunning && !z2 && i10 < i40 + byteArrayToInt_Little2) {
                                            boolean z16 = this.mOssDownEnd;
                                            if (!z16) {
                                                z2 = this.OSSLoadFin;
                                                i10 = this.SaveOssLoad;
                                            }
                                            if (z2 && !z16) {
                                                this.mOssDownEnd = true;
                                            }
                                            hiThread.sleep(100);
                                        }
                                        int HiH264ReadFrameOSSData = PlayLocalFile.HiH264ReadFrameOSSData(this.ossread_readhandle[0], MallocByte2, iArr, MallocByte);
                                        HiLog.e("======== ThreadPlayLocal  read ========:::" + HiH264ReadFrameOSSData + ":::" + iArr[0] + ":::" + iArr[1] + "::size:" + iArr[4] + ":frameflag::" + iArr[5] + "::videoflag::" + iArr[6]);
                                        if (HiH264ReadFrameOSSData == 0) {
                                            int i41 = iArr[4];
                                            int i42 = i40 + i41;
                                            if (iArr[5] == 1229346888) {
                                                if (!this.isSeekend) {
                                                    hiThread.sleep(500);
                                                    this.isPlayEnd = true;
                                                    break;
                                                }
                                                hiThread.sleep(1000);
                                                i18 = byteArrayToInt_Little2;
                                                i19 = byteArrayToInt_Little;
                                                i20 = HiH264ReadFrameOSSData;
                                                z4 = z2;
                                                i13 = i10;
                                                bArr5 = MallocByte;
                                                i14 = i29;
                                                bArr7 = bArr4;
                                                j6 = j8;
                                                i32 = i9;
                                                z5 = false;
                                                bArr8 = MallocByte2;
                                                i29 = i14;
                                                r8 = z5;
                                                i24 = i13;
                                                z11 = z4;
                                                jArr3 = jArr2;
                                                MallocByte3 = bArr7;
                                                i33 = i42;
                                                MallocByte = bArr5;
                                                j8 = j6;
                                                i25 = i18;
                                                i26 = i19;
                                                MallocByte2 = bArr8;
                                                z10 = true;
                                                i27 = i20;
                                                j7 = j;
                                            } else {
                                                if (i41 > this.maxlen) {
                                                    break;
                                                }
                                                if (this.mIsOCloud && iArr[6] == 1) {
                                                    i13 = i10;
                                                    bArr5 = MallocByte;
                                                    j5 = j;
                                                    DoAes.HiOCloudEDncrypt(j5, MallocByte2, 128);
                                                } else {
                                                    i13 = i10;
                                                    bArr5 = MallocByte;
                                                    j5 = j;
                                                }
                                                int i43 = this.savespeed;
                                                if (i43 < 3 || (i43 > 2 && iArr[6] == 1)) {
                                                    i14 = i29;
                                                } else {
                                                    if (!this.isH265DevDec || i43 <= 2) {
                                                        i14 = i29;
                                                    } else {
                                                        i14 = i29;
                                                    }
                                                    i18 = byteArrayToInt_Little2;
                                                    i19 = byteArrayToInt_Little;
                                                    i20 = HiH264ReadFrameOSSData;
                                                    z4 = z2;
                                                    j = j5;
                                                    bArr7 = bArr4;
                                                    j6 = j8;
                                                    i32 = i9;
                                                    z5 = false;
                                                    bArr8 = MallocByte2;
                                                    i29 = i14;
                                                    r8 = z5;
                                                    i24 = i13;
                                                    z11 = z4;
                                                    jArr3 = jArr2;
                                                    MallocByte3 = bArr7;
                                                    i33 = i42;
                                                    MallocByte = bArr5;
                                                    j8 = j6;
                                                    i25 = i18;
                                                    i26 = i19;
                                                    MallocByte2 = bArr8;
                                                    z10 = true;
                                                    i27 = i20;
                                                    j7 = j;
                                                }
                                                if (i41 > 0) {
                                                    int i44 = iArr[6];
                                                    if (this.isH265DevDec) {
                                                        i29 = i14 + 1;
                                                        if (1 == i44) {
                                                            i29 = 0;
                                                        }
                                                    } else {
                                                        i29 = i14;
                                                    }
                                                    if (1180063816 == iArr[5]) {
                                                        bArr6 = bArr4;
                                                        System.arraycopy(MallocByte2, 0, bArr6, 0, i41);
                                                        i15 = 0 + i41;
                                                        i34 = 1180063816;
                                                        c = 4;
                                                    } else {
                                                        bArr6 = bArr4;
                                                        if (1178687560 == iArr[5]) {
                                                            int i45 = i41 - 4;
                                                            c = 4;
                                                            System.arraycopy(MallocByte2, 4, bArr6, 0, i45);
                                                            i15 = i45 + 0;
                                                            i34 = 1178687560;
                                                        } else {
                                                            c = 4;
                                                            i15 = 0;
                                                        }
                                                    }
                                                    if (this.savespeed > 2) {
                                                        i16 = i9;
                                                        if (i16 != 2) {
                                                            z4 = z2;
                                                            i16 = 2;
                                                            i17 = 2;
                                                            int i46 = i16;
                                                            j = j5;
                                                            j6 = j8;
                                                            i18 = byteArrayToInt_Little2;
                                                            i19 = byteArrayToInt_Little;
                                                            i20 = HiH264ReadFrameOSSData;
                                                            z5 = false;
                                                            bArr7 = bArr6;
                                                            bArr8 = MallocByte2;
                                                            save2Queue(MallocByte4, bArr6, i15, iArr[5], i34, (iArr[0] * 10000) + iArr[1], i44, i29, Boolean.valueOf(hiThread.isRunning));
                                                            z6 = this.isLoading_FLAG;
                                                            if (z6) {
                                                                if (i30 == 0) {
                                                                    i21 = 1;
                                                                    i30 = (iArr[0] * 10000) + iArr[1];
                                                                } else {
                                                                    i21 = 1;
                                                                }
                                                                i23 = ((iArr[0] * 10000) + iArr[i21]) - i30;
                                                                i22 = i44;
                                                            } else {
                                                                i21 = 1;
                                                                i22 = i44;
                                                                i23 = i31;
                                                            }
                                                            if (i22 == i21 && z6) {
                                                                this.Loading_IFrameNum += i21;
                                                            }
                                                            if (z6 && (frameQueue3 = this.mossVideoFrameQueue) != null && (this.Loading_IFrameNum >= this.Loading_IFrameNum_tal || i23 > this.Loading_FramePts * 1000 || frameQueue3.getCount() >= this.Loading_FrameNum)) {
                                                                this.isLoading_FLAG = false;
                                                                StringBuilder sb4 = new StringBuilder();
                                                                sb4.append("");
                                                                sb4.append(this.Loading_IFrameNum);
                                                                sb4.append("::::");
                                                                sb4.append(i23);
                                                                sb4.append(":::");
                                                                FrameQueue frameQueue12 = this.mossVideoFrameQueue;
                                                                sb4.append(frameQueue12 != null ? frameQueue12.getCount() : -1);
                                                                HiLog.e(sb4.toString(), 1, 0);
                                                                setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, 22);
                                                                i30 = 0;
                                                            }
                                                            while (hiThread.isRunning && this.isPlaying && (frameQueue2 = this.mossVideoFrameQueue) != null && frameQueue2.getCount() >= i46) {
                                                                hiThread.sleep(2);
                                                            }
                                                            while (hiThread.isRunning && this.isPlaying && (frameQueue = this.mossAudioFrameQueue) != null && frameQueue.getCount() >= i17) {
                                                                hiThread.sleep(2);
                                                            }
                                                            i31 = i23;
                                                            i35 = i17;
                                                            i32 = i46;
                                                        }
                                                        z4 = z2;
                                                        i17 = i35;
                                                        int i462 = i16;
                                                        j = j5;
                                                        j6 = j8;
                                                        i18 = byteArrayToInt_Little2;
                                                        i19 = byteArrayToInt_Little;
                                                        i20 = HiH264ReadFrameOSSData;
                                                        z5 = false;
                                                        bArr7 = bArr6;
                                                        bArr8 = MallocByte2;
                                                        save2Queue(MallocByte4, bArr6, i15, iArr[5], i34, (iArr[0] * 10000) + iArr[1], i44, i29, Boolean.valueOf(hiThread.isRunning));
                                                        z6 = this.isLoading_FLAG;
                                                        if (z6) {
                                                        }
                                                        if (i22 == i21) {
                                                            this.Loading_IFrameNum += i21;
                                                        }
                                                        if (z6) {
                                                            this.isLoading_FLAG = false;
                                                            StringBuilder sb42 = new StringBuilder();
                                                            sb42.append("");
                                                            sb42.append(this.Loading_IFrameNum);
                                                            sb42.append("::::");
                                                            sb42.append(i23);
                                                            sb42.append(":::");
                                                            FrameQueue frameQueue122 = this.mossVideoFrameQueue;
                                                            sb42.append(frameQueue122 != null ? frameQueue122.getCount() : -1);
                                                            HiLog.e(sb42.toString(), 1, 0);
                                                            setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, 22);
                                                            i30 = 0;
                                                        }
                                                        while (hiThread.isRunning) {
                                                            hiThread.sleep(2);
                                                        }
                                                        while (hiThread.isRunning) {
                                                            hiThread.sleep(2);
                                                        }
                                                        i31 = i23;
                                                        i35 = i17;
                                                        i32 = i462;
                                                    } else {
                                                        i16 = i9;
                                                        if (z2) {
                                                            if (i16 != 8) {
                                                                i16 = 8;
                                                                z4 = z2;
                                                                i17 = 8;
                                                            }
                                                            z4 = z2;
                                                            i17 = i35;
                                                        } else {
                                                            if (i16 != 100) {
                                                                i16 = 100;
                                                                z4 = z2;
                                                                i17 = 100;
                                                            }
                                                            z4 = z2;
                                                            i17 = i35;
                                                        }
                                                        int i4622 = i16;
                                                        j = j5;
                                                        j6 = j8;
                                                        i18 = byteArrayToInt_Little2;
                                                        i19 = byteArrayToInt_Little;
                                                        i20 = HiH264ReadFrameOSSData;
                                                        z5 = false;
                                                        bArr7 = bArr6;
                                                        bArr8 = MallocByte2;
                                                        save2Queue(MallocByte4, bArr6, i15, iArr[5], i34, (iArr[0] * 10000) + iArr[1], i44, i29, Boolean.valueOf(hiThread.isRunning));
                                                        z6 = this.isLoading_FLAG;
                                                        if (z6) {
                                                        }
                                                        if (i22 == i21) {
                                                        }
                                                        if (z6) {
                                                        }
                                                        while (hiThread.isRunning) {
                                                        }
                                                        while (hiThread.isRunning) {
                                                        }
                                                        i31 = i23;
                                                        i35 = i17;
                                                        i32 = i4622;
                                                    }
                                                    r8 = z5;
                                                    i24 = i13;
                                                    z11 = z4;
                                                    jArr3 = jArr2;
                                                    MallocByte3 = bArr7;
                                                    i33 = i42;
                                                    MallocByte = bArr5;
                                                    j8 = j6;
                                                    i25 = i18;
                                                    i26 = i19;
                                                    MallocByte2 = bArr8;
                                                    z10 = true;
                                                    i27 = i20;
                                                    j7 = j;
                                                }
                                                i18 = byteArrayToInt_Little2;
                                                i19 = byteArrayToInt_Little;
                                                i20 = HiH264ReadFrameOSSData;
                                                z4 = z2;
                                                j = j5;
                                                bArr7 = bArr4;
                                                j6 = j8;
                                                i32 = i9;
                                                z5 = false;
                                                bArr8 = MallocByte2;
                                                i29 = i14;
                                                r8 = z5;
                                                i24 = i13;
                                                z11 = z4;
                                                jArr3 = jArr2;
                                                MallocByte3 = bArr7;
                                                i33 = i42;
                                                MallocByte = bArr5;
                                                j8 = j6;
                                                i25 = i18;
                                                i26 = i19;
                                                MallocByte2 = bArr8;
                                                z10 = true;
                                                i27 = i20;
                                                j7 = j;
                                            }
                                        } else {
                                            i = 0;
                                            HiLog.e("======== ThreadPlayLocal  end ========", 1, 0);
                                            hiThread.sleep(500);
                                            this.isPlayEnd = true;
                                            break;
                                        }
                                    } else {
                                        this.isPlayossEnd = true;
                                        z3 = true;
                                        HiLog.e(z2 + ":SaveOssLoad:" + i10 + ":ossreadloc:" + i40 + ":framelen:" + byteArrayToInt_Little2 + ":::" + ((int) MallocByte[0]) + ((int) MallocByte[1]) + ((int) MallocByte[2]) + ((int) MallocByte[3]) + ((int) MallocByte[4]) + ((int) MallocByte[5]) + ((int) MallocByte[6]) + ((int) MallocByte[7]) + ((int) MallocByte[8]) + ((int) MallocByte[9]) + ((int) MallocByte[10]) + ((int) MallocByte[11]) + ((int) MallocByte[12]) + ((int) MallocByte[13]) + ((int) MallocByte[14]) + ((int) MallocByte[15]), 1, 0);
                                        hiThread.sleep(100);
                                        i33 = i40;
                                        i27 = HiH264ReadFrameOSSHead;
                                        i25 = byteArrayToInt_Little2;
                                        i26 = byteArrayToInt_Little;
                                        z11 = z2;
                                        i24 = i10;
                                        jArr3 = jArr2;
                                        MallocByte3 = bArr4;
                                        i32 = i9;
                                        j7 = j;
                                        r8 = 0;
                                        z10 = z3;
                                    }
                                } else {
                                    if (!this.isSeekend) {
                                        hiThread.sleep(500);
                                        this.isPlayEnd = true;
                                        this.isPlayossEnd = true;
                                        this.isLoading_FLAG = false;
                                        setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, 22);
                                        HiLog.e("", 1, 0);
                                        i = 0;
                                        break;
                                    }
                                    hiThread.sleep(1000);
                                    z3 = true;
                                    i33 = i40;
                                    i27 = HiH264ReadFrameOSSHead;
                                    i25 = byteArrayToInt_Little2;
                                    i26 = byteArrayToInt_Little;
                                    z11 = z2;
                                    i24 = i10;
                                    jArr3 = jArr2;
                                    MallocByte3 = bArr4;
                                    i32 = i9;
                                    j7 = j;
                                    r8 = 0;
                                    z10 = z3;
                                }
                            } else {
                                i33 = i11;
                                i27 = HiH264ReadFrameOSSHead;
                                i25 = byteArrayToInt_Little2;
                                i26 = byteArrayToInt_Little;
                                z10 = r9;
                                z11 = z2;
                                i24 = i10;
                                jArr3 = jArr2;
                                MallocByte3 = bArr4;
                                i32 = i9;
                                j7 = j;
                                r8 = 0;
                            }
                        } else {
                            HiLog.e(i12 + "::" + i25 + ":::" + Integer.toHexString(i26) + "::" + z2 + ":::" + i10 + "::::" + i11, r9, 0);
                            hiThread.sleep(100);
                            i33 = i11;
                            i27 = i12;
                            z10 = r9;
                            z11 = z2;
                            i24 = i10;
                            j8 = j4;
                            jArr3 = jArr2;
                            MallocByte3 = bArr4;
                            i32 = i9;
                            j7 = j;
                            r8 = 0;
                        }
                    }
                }
                i8 = i32;
                synchronized (this) {
                }
            }
            hiThread.sleep(i6);
            z10 = true;
            HiLog.e("======== ThreadPlayLocal   ========" + this.isPlaying + ":::::" + hiThread.isRunning, 1, i3);
            i29 = i5;
            j8 = j3;
            jArr3 = jArr;
            MallocByte3 = bArr3;
            MallocByte2 = bArr;
            j7 = j2;
            i25 = i4;
            r8 = i3;
            MallocByte = bArr2;
        }
        if (this.mIsOCloud) {
            DoAes.HiOCloudDinit(j);
        }
        if (this.isPlayStop && this.video_type == this.VIDEO_TYPE_H264) {
            i2 = 1;
            HiLog.e("" + this.isPlayossEnd, 1, i);
            Playlocal_CloseH264();
            HiLog.e(this.saveOssLoadLen + "::::" + this.mOssFilesize, 1, i);
        } else {
            i2 = 1;
        }
        HiLog.e("======== ThreadPlayLocal  end ========", i2, i);
    }

    public void DoDecodeAudio(HiThread hiThread) {
        ThreadDecodeAudioCloud threadDecodeAudioCloud;
        HiLog.e("======== ThreadDecodeAudio  start ========" + this.isLoading_FLAG, 1, 0);
        HiAudioPlay hiAudioPlay = new HiAudioPlay();
        if (!hiAudioPlay.init(this.audiotype) && (threadDecodeAudioCloud = this.mThreadDecodeAudioCloud) != null) {
            threadDecodeAudioCloud.weakup();
            this.mThreadDecodeAudioCloud.stopThread();
        }
        while (hiThread.isRunning) {
            if (this.isLoading_FLAG || this.mossAudioFrameQueue == null) {
                hiThread.sleep(20);
            } else {
                hiAudioPlay.setaudiotype(this.audiotype);
                FrameQueue frameQueue = this.mossAudioFrameQueue;
                if (frameQueue != null && frameQueue.getCount() > 0 && this.video_type != this.VIDEO_TYPE_MP4) {
                    FrameQueue frameQueue2 = this.mossAudioFrameQueue;
                    if (frameQueue2 != null && frameQueue2.getCount() <= 0) {
                        hiThread.sleep(20);
                    } else {
                        FrameQueue frameQueue3 = this.mossAudioFrameQueue;
                        if (frameQueue3 == null || this.mossVideoFrameQueue == null) {
                            break;
                        }
                        FrameData removeHead = frameQueue3.removeHead();
                        if (removeHead != null) {
                            int frmSize = removeHead.getFrmSize();
                            if (this.video_type != this.VIDEO_TYPE_MP4) {
                                if (!this.is2Mp4) {
                                    long currentTimeMillis = System.currentTimeMillis();
                                    hiAudioPlay.audioPlay(removeHead.frmData, frmSize, true);
                                    int currentTimeMillis2 = (int) ((20 - (System.currentTimeMillis() - currentTimeMillis)) - 8);
                                    if (currentTimeMillis2 < 20 && currentTimeMillis2 > 0) {
                                        hiThread.sleep(currentTimeMillis2);
                                    }
                                } else {
                                    byte[] audioPlay = hiAudioPlay.audioPlay(removeHead.frmData, frmSize, false);
                                    this.writemp4lock.lock();
                                    long[] jArr = this.mp4_handle;
                                    if (jArr[0] != 0) {
                                        EncMp4.HIEncMp4write(jArr[0], audioPlay, 320, 2, removeHead.getTimeStamp(), 0);
                                    }
                                    this.writemp4lock.unlock();
                                }
                            } else {
                                long currentTimeMillis3 = System.currentTimeMillis();
                                hiAudioPlay.audioPlay(removeHead.frmData, frmSize, true);
                                int currentTimeMillis4 = (int) ((20 - (System.currentTimeMillis() - currentTimeMillis3)) - 8);
                                if (currentTimeMillis4 < 20 && currentTimeMillis4 > 0) {
                                    hiThread.sleep(currentTimeMillis4);
                                }
                            }
                        }
                    }
                }
            }
        }
        hiAudioPlay.setaudiotype(1);
        hiAudioPlay.uninit();
        HiLog.e("mSessionHandle:======== ThreadDecodeAudio  end ========uid_byte::::", 1, 0);
    }

    public class ThreadDecodeAudioCloud extends HiThread {
        private ThreadDecodeAudioCloud() {
        }

        @Override
        public void run() {
            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
            hiPlayOSSSDK.DoDecodeAudio(hiPlayOSSSDK.mThreadDecodeAudioCloud);
        }
    }

    public void DoDecodeVideo(HiThread hiThread) {
        int i;
        String str;
        long[] jArr;
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        long j;
        FrameData frameData;
        long j2;
        String str2;
        long j3;
        int i7;
        int i8;
        char c;
        int i9;
        HiGLMonitor hiGLMonitor;
        FrameQueue frameQueue;
        int i10;
        int i11;
        int HIH264Dec_init;
        int i12;
        int i13 = 0;
        HiLog.e("======== ThreadDecodeVideo  start ========", 1, 0);
        long[] jArr2 = new long[1];
        Boolean bool = false;
        Boolean.valueOf(true);
        int i14 = this.videoheight;
        if (i14 < 0 || (i12 = this.videowidth) < 0 || i14 > 5000 || i12 > 5000) {
            hiThread.isRunning = false;
        }
        int i15 = ((this.videowidth * this.videoheight) * 3) / 2;
        FrameData frameData2 = null;
        int i16 = Build.VERSION.SDK_INT;
        if (!hiThread.isRunning || this.is2Mp4 || i15 <= 0) {
            i = 5;
            str = "";
        } else {
            byte[] MallocByte = Packet.MallocByte(i15);
            this.yuvBuffer = MallocByte;
            if (MallocByte == null) {
                HiLog.e("", 1, 1);
                i = 5;
                str = "";
                i10 = 4;
                i11 = i16;
                setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, -1);
                hiThread.isRunning = false;
            } else {
                i = 5;
                str = "";
                i10 = 4;
                i11 = i16;
            }
            if (this.videotype != i) {
                this.videotype = i10;
            }
            if (this.DecodeVideoType != 1) {
                this.DecodeVideoType = 0;
            }
            if (this.DecodeViVoVideoType == 1) {
                int i17 = this.videotype;
                if (i17 == i10) {
                    if (i11 < 16 || this.DecodeVideoType == 0) {
                        HIH264Dec_init = H264Decoder.HIH264Dec_init(jArr2, 0, i17);
                    } else {
                        HIH264Dec_init = H264Decoder.HIH264Dec_init(jArr2, 1, i17);
                    }
                } else if (i11 < 23) {
                    HIH264Dec_init = H264Decoder.HIH264Dec_init(jArr2, 0, i17);
                } else {
                    HIH264Dec_init = H264Decoder.HIH264Dec_init(jArr2, 1, i17);
                }
            } else {
                HIH264Dec_init = H264Decoder.HIH264Dec_init(jArr2, 0, this.videotype);
            }
            if (HIH264Dec_init < 0) {
                HiLog.e(str, 1, 1);
                hiThread.isRunning = false;
                if (this.videotype == i) {
                    setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, -5);
                } else {
                    setplaylocal(this.videowidth, this.videoheight, this.filetime, 0L, this.audiotype, -4);
                }
            }
        }
        char c2 = 0;
        int i18 = 0;
        boolean z = false;
        long j4 = 0;
        while (hiThread.isRunning) {
            if (!this.isPlaying) {
                jArr = jArr2;
                i4 = 20;
            } else if (this.mossVideoFrameQueue == null) {
                i4 = 20;
                jArr = jArr2;
            } else {
                if (this.videotype == i && this.mDeciveInfo.getDeviceDecode5() != this.isDeviceDecode5) {
                    this.isDeviceDecode5 = this.mDeciveInfo.getDeviceDecode5();
                    H264Decoder.HIH264Dec_uninit(jArr2[i13]);
                    H264Decoder.HIH264Dec_init(jArr2, i13, this.videotype);
                }
                if (this.isDisplayFrist && this.isLoading_FLAG) {
                    hiThread.sleep(20);
                    jArr = jArr2;
                } else {
                    if (1 != c2) {
                        j4 = System.currentTimeMillis();
                    }
                    if (c2 == 2 || ((frameQueue = this.mossVideoFrameQueue) != null && frameQueue.getCount() > 0)) {
                        if (i18 != 0 || (frameData2 = this.mossVideoFrameQueue.removeHead()) != null) {
                            if (1 == c2) {
                                frameData2 = this.mossVideoFrameQueue.removeHead();
                                if (frameData2 == null) {
                                    i = 5;
                                } else {
                                    this.u32AVFramePTS1 = frameData2.getTimeStamp();
                                    long currentTimeMillis = System.currentTimeMillis();
                                    if (currentTimeMillis < j4) {
                                        currentTimeMillis += 1000;
                                    }
                                    jArr = jArr2;
                                    long j5 = currentTimeMillis;
                                    if (hiThread.isRunning && !this.isSeek && this.savespeed == 0) {
                                        int i19 = (this.u32AVFramePTS1 - i18) - ((int) (j5 - j4));
                                        HiLog.e("dec -----  start " + j4 + ":::" + j5 + ":::" + this.u32AVFramePTS1 + ":::" + i18 + ":::" + i19 + ":::" + this.isSeek);
                                        if (i19 <= 0 || i19 >= 1000) {
                                            i5 = 500;
                                            if (i19 > 1000) {
                                                hiThread.sleep(500);
                                            }
                                        } else {
                                            hiThread.sleep(i19);
                                            i5 = 500;
                                        }
                                    } else {
                                        i5 = 500;
                                        if (hiThread.isRunning) {
                                            int i20 = this.saveInterval;
                                            int i21 = ((this.u32AVFramePTS1 - i18) * i20) / 40;
                                            int i22 = this.savespeed;
                                            if (i22 == 1) {
                                                if (i20 != 0) {
                                                    long j6 = j5 - j4;
                                                    if (i21 > j6) {
                                                        hiThread.sleep(i21 - ((int) j6));
                                                    }
                                                }
                                            } else if (i22 == 2) {
                                                if (i20 != 0) {
                                                    long j7 = j5 - j4;
                                                    if (i21 > j7) {
                                                        hiThread.sleep(i21 - ((int) j7));
                                                    }
                                                }
                                            } else if (i22 > 2 && i20 != 0 && this.mThreadDecodeVideoCloud != null && frameData2.isIFrame()) {
                                                DecodeSleep(this.mThreadDecodeVideoCloud, (int) (j5 - j4));
                                            }
                                        }
                                    }
                                    i6 = this.u32AVFramePTS1;
                                    j = System.currentTimeMillis();
                                    frameData = frameData2;
                                    c2 = 0;
                                }
                            } else {
                                jArr = jArr2;
                                i5 = 500;
                                i6 = i18;
                                j = j4;
                                frameData = frameData2;
                            }
                            if (this.isqueueenpty && !frameData.isIFrame()) {
                                hiThread.sleep(20);
                                j4 = j;
                                i18 = i6;
                            } else {
                                if (true == this.isqueueenpty) {
                                    this.isqueueenpty = false;
                                }
                                char c3 = 2 == c2 ? (char) 0 : c2;
                                StringBuilder sb = new StringBuilder();
                                sb.append(str);
                                sb.append(frameData.getFrmSize());
                                sb.append("::");
                                sb.append(frameData.getFrameFlag());
                                sb.append("::");
                                sb.append(frameData.getTimeStamp());
                                sb.append("getCount:");
                                FrameQueue frameQueue2 = this.mossVideoFrameQueue;
                                sb.append(frameQueue2 != null ? frameQueue2.getCount() : -1);
                                sb.append(":::::");
                                sb.append(this.mossAudioFrameQueue.getCount());
                                sb.append("::");
                                sb.append(this.isDisplayFrist);
                                sb.append(":::");
                                sb.append(frameData.isIFrame());
                                HiLog.e(sb.toString(), 1, 0);
                                if (frameData.getFrmSize() > 0) {
                                    if (!this.is2Mp4) {
                                        if (!z) {
                                            if (frameData.isIFrame()) {
                                                z = true;
                                            }
                                        }
                                        int timeStamp = frameData.getTimeStamp();
                                        if (!hiThread.isRunning) {
                                            break;
                                        }
                                        int HIH264Dec_decoder = H264Decoder.HIH264Dec_decoder(jArr[0], frameData.frmData, frameData.getFrmSize(), this.videowidth, this.videoheight, this.yuvBuffer, frameData.isIFrame());
                                        if (!hiThread.isRunning) {
                                            break;
                                        }
                                        if (HIH264Dec_decoder == 0 && !this.isDisplayFrist) {
                                            this.isDisplayFrist = true;
                                        }
                                        if (this.mMonitor == null || HIH264Dec_decoder != 0) {
                                            str2 = "dec -----  start ";
                                            j3 = j;
                                            i7 = timeStamp;
                                            i8 = i5;
                                            if (HIH264Dec_decoder < -100) {
                                                this.mDeciveInfo.setDeviceDecode5(false);
                                            }
                                        } else {
                                            if (!z || bool.booleanValue()) {
                                                str2 = "dec -----  start ";
                                                j3 = j;
                                                i7 = timeStamp;
                                                i9 = 1;
                                                i8 = i5;
                                            } else {
                                                HiLog.e("PlayOSSFileCallback.PLAYLOCAL_STATE_START::::" + this.videowidth + "::::" + this.videoheight, 1, 0);
                                                if (this.mFirstTime == 0) {
                                                    this.mFirstTime = frameData.getTimeStamp();
                                                }
                                                i7 = timeStamp;
                                                j3 = j;
                                                str2 = "dec -----  start ";
                                                i8 = i5;
                                                setplaylocal(this.videowidth, this.videoheight, this.filetime, frameData.getTimeStamp(), this.audiotype, 1);
                                                i9 = 1;
                                                bool = true;
                                            }
                                            if (this.mMonitor.setYuvFrameData(this.yuvBuffer, this.videowidth, this.videoheight) < 0) {
                                                HiLog.e(str, i9, i9);
                                                setplaylocal(this.videowidth, this.videoheight, this.filetime, frameData.getTimeStamp(), this.audiotype, 5);
                                            }
                                            if (this.mSpliceDev && (hiGLMonitor = this.mMonitorSpliceview) != null) {
                                                hiGLMonitor.setYuvFrameData(this.yuvBuffer, this.videowidth, this.videoheight);
                                            }
                                        }
                                        this.subtime = (frameData.getTimeStamp() - this.mFirstTime) / 1000;
                                        if (this.isH265DevDec && this.savespeed > 2) {
                                            if (frameData.isIFrame()) {
                                                setplaylocal(this.videowidth, this.videoheight, this.filetime, frameData.getTimeStamp(), this.audiotype, 2);
                                            }
                                        } else {
                                            setplaylocal(this.videowidth, this.videoheight, this.filetime, frameData.getTimeStamp(), this.audiotype, 2);
                                        }
                                        FrameQueue frameQueue3 = this.mossVideoFrameQueue;
                                        if (frameQueue3 == null || frameQueue3.getCount() <= 0) {
                                            i18 = i7;
                                            j4 = j3;
                                        } else {
                                            FrameData removeHead = this.mossVideoFrameQueue.removeHead();
                                            if (removeHead == null) {
                                                HiLog.e("======== ThreadDecodeVideo mVideoFrameQueue.removeHead     end    ========", 1, 0);
                                                i13 = 0;
                                                i18 = i7;
                                                jArr2 = jArr;
                                                j4 = j3;
                                                i = 5;
                                                frameData2 = removeHead;
                                                c2 = 1;
                                            } else {
                                                this.u32AVFramePTS1 = removeHead.getTimeStamp();
                                                long currentTimeMillis2 = System.currentTimeMillis();
                                                long j8 = j3;
                                                if (currentTimeMillis2 < j8) {
                                                    currentTimeMillis2 += 1000;
                                                }
                                                if (hiThread.isRunning && !this.isSeek && this.savespeed == 0) {
                                                    int i23 = (this.u32AVFramePTS1 - i7) - ((int) (currentTimeMillis2 - j8));
                                                    HiLog.e(str2 + j8 + ":::" + currentTimeMillis2 + ":::" + this.u32AVFramePTS1 + ":::" + i7 + ":::" + i23 + ":::" + this.isSeek);
                                                    if (i23 > 0 && i23 < 1000) {
                                                        hiThread.sleep(i23);
                                                    } else if (i23 > 1000) {
                                                        hiThread.sleep(i8);
                                                    }
                                                } else {
                                                    int i24 = i7;
                                                    if (hiThread.isRunning) {
                                                        int i25 = this.saveInterval;
                                                        int i26 = ((this.u32AVFramePTS1 - i24) * i25) / 40;
                                                        int i27 = this.savespeed;
                                                        if (i27 != 1) {
                                                            c = 2;
                                                            if (i27 != 2) {
                                                                if (i27 > 2 && i25 != 0 && this.mThreadDecodeVideoCloud != null && removeHead.isIFrame()) {
                                                                    DecodeSleep(this.mThreadDecodeVideoCloud, (int) (currentTimeMillis2 - j8));
                                                                }
                                                                i18 = this.u32AVFramePTS1;
                                                                frameData2 = removeHead;
                                                                j4 = j8;
                                                                c2 = c;
                                                            } else if (i25 != 0) {
                                                                long j9 = currentTimeMillis2 - j8;
                                                                if (i26 > j9) {
                                                                    hiThread.sleep(i26 - ((int) j9));
                                                                }
                                                            }
                                                        } else if (i25 != 0) {
                                                            long j10 = currentTimeMillis2 - j8;
                                                            if (i26 > j10) {
                                                                hiThread.sleep(i26 - ((int) j10));
                                                            }
                                                        }
                                                    }
                                                }
                                                c = 2;
                                                i18 = this.u32AVFramePTS1;
                                                frameData2 = removeHead;
                                                j4 = j8;
                                                c2 = c;
                                            }
                                        }
                                    } else {
                                        long j11 = j;
                                        this.writemp4lock.lock();
                                        if (this.mp4_handle[0] != 0) {
                                            if (frameData.isIFrame()) {
                                                EncMp4.HIEncMp4write(this.mp4_handle[0], frameData.frmData, frameData.getFrmSize(), 0, frameData.getTimeStamp(), 0);
                                            } else {
                                                EncMp4.HIEncMp4write(this.mp4_handle[0], frameData.frmData, frameData.getFrmSize(), 1, frameData.getTimeStamp(), 0);
                                            }
                                        }
                                        this.writemp4lock.unlock();
                                        j2 = j11;
                                        setplaylocal(this.videowidth, this.videoheight, this.filetime, frameData.getTimeStamp(), this.audiotype, 12);
                                        i18 = i6;
                                        c2 = c3;
                                        j4 = j2;
                                        i13 = 0;
                                        i = 5;
                                        frameData2 = frameData;
                                        jArr2 = jArr;
                                    }
                                }
                                j2 = j;
                                i18 = i6;
                                c2 = c3;
                                j4 = j2;
                                i13 = 0;
                                i = 5;
                                frameData2 = frameData;
                                jArr2 = jArr;
                            }
                            frameData2 = frameData;
                            jArr2 = jArr;
                            c2 = 1;
                            i13 = 0;
                            i = 5;
                        }
                    } else if (hiThread.isRunning) {
                        HiLog.e(str, 1, i13);
                        if (this.isPlayEnd) {
                            break;
                        } else {
                            hiThread.sleep(20);
                        }
                    } else {
                        continue;
                    }
                }
                jArr2 = jArr;
                i13 = 0;
                i = 5;
            }
            hiThread.sleep(i4);
            jArr2 = jArr;
            i13 = 0;
            i = 5;
        }
        jArr = jArr2;
        if (!this.is2Mp4) {
            H264Decoder.HIH264Dec_uninit(jArr[0]);
            if (this.isPlayEnd) {
                i3 = 3;
            } else {
                i3 = this.isPlayStop ? 4 : -1;
            }
            int i28 = this.videowidth;
            int i29 = this.videoheight;
            int i30 = this.filetime;
            setplaylocal(i28, i29, i30, i30, this.audiotype, i3);
        } else {
            if (this.isPlayEnd) {
                i2 = 13;
            } else {
                i2 = this.isPlayStop ? 14 : -11;
            }
            int i31 = i2;
            this.writemp4lock.lock();
            long[] jArr3 = this.mp4_handle;
            if (jArr3[0] != 0) {
                EncMp4.HIEncMp4deinit(jArr3[0]);
                this.mp4_handle[0] = 0;
            }
            this.writemp4lock.unlock();
            int i32 = this.videowidth;
            int i33 = this.videoheight;
            int i34 = this.filetime;
            setplaylocal(i32, i33, i34, i34, this.audiotype, i31);
        }
        HiLog.e("======== ThreadDecodeVideo  end ========", 1, 0);
    }

    public class ThreadDecodeVideoCloud extends HiThread {
        private ThreadDecodeVideoCloud() {
        }

        public byte[] getYuvBuffer() {
            return HiPlayOSSSDK.this.yuvBuffer;
        }

        @Override
        public void run() {
            HiPlayOSSSDK hiPlayOSSSDK = HiPlayOSSSDK.this;
            hiPlayOSSSDK.DoDecodeVideo(hiPlayOSSSDK.mThreadDecodeVideoCloud);
        }
    }

    public static void renameFile(String str, String str2) {
        HiLog.e(str, 1, 0);
        HiLog.e(str2, 1, 0);
        new File(str).renameTo(new File(str2));
    }

    boolean delFile(String str) {
        File file = new File(str);
        if (!file.exists()) {
            return false;
        }
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                delFile(file2.getPath());
            }
        }
        return file.delete();
    }

    public HiConfig getHiConfig() {
        if (this.mhiConfig == null) {
            HiConfig hiConfig = new HiConfig();
            this.mhiConfig = hiConfig;
            hiConfig.setOSS_UUID("BBBB-000000-CDEFG");
        }
        return this.mhiConfig;
    }

    public class ThreadOSSFileList extends HiThread {
        private ThreadOSSFileList() {
        }

        @Override
        public void run() {
            if (HiPlayOSSSDK.this.mhiConfig != null) {
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_objectKey(), 1, 0);
                HiPlayOSSSDK.this.mhiCloud.GetOSSFilelist(HiPlayOSSSDK.this.mhiConfig, HiPlayOSSSDK.this.cumhandler, 28672);
            }
        }
    }

    public class ThreadOSSdoesobj extends HiThread {
        private ThreadOSSdoesobj() {
        }

        @Override
        public void run() {
            if (HiPlayOSSSDK.this.mhiConfig != null) {
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getBUCKET_NAME(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
                HiLog.e(HiPlayOSSSDK.this.mhiConfig.getOSS_objectKey(), 1, 0);
                HiPlayOSSSDK.this.mhiCloud.GetOSSdoesObject(HiPlayOSSSDK.this.mhiConfig, HiPlayOSSSDK.this.cumhandler, 28928);
            }
        }
    }

    public void GetOSSFilelistExt(String str, int i) {
        String replaceAll;
        HiLog.e("" + i, 1, 0);
        if (i != 0) {
            this.mcumCounttry = 0;
        }
        if (this.mhiConfig != null) {
            HiLog.e("" + str + "::::" + this.isPlayStop, 1, 0);
            if (i != 0) {
                if (str != null) {
                    this.mhiConfig.setOSS_objectKey(str);
                } else {
                    HiConfig hiConfig = this.mhiConfig;
                    hiConfig.setOSS_objectKey(hiConfig.getOSS_UUID());
                }
            }
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            HiLog.e(this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
            HiLog.e(this.mhiConfig.getBUCKET_NAME(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
            if (System.currentTimeMillis() - this.mSaveOssGetTime > 3600000 - this.mSetOsstime) {
                if (this.mIsOCloud) {
                    Timer timer = this.mUidEXIPREtimer;
                    if (timer != null) {
                        timer.cancel();
                    }
                    this.mUidEXIPREtimer = null;
                    this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                } else {
                    this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                }
                this.mOssOperation = 5;
                return;
            }
            ThreadOSSFileList threadOSSFileList = this.mthreadossfilelist;
            if (threadOSSFileList != null) {
                threadOSSFileList.weakup();
                this.mthreadossfilelist.stopThread();
                this.mthreadossfilelist = null;
            }
            if (this.mthreadossfilelist == null) {
                ThreadOSSFileList threadOSSFileList2 = new ThreadOSSFileList();
                this.mthreadossfilelist = threadOSSFileList2;
                threadOSSFileList2.startThread();
            }
        }
    }

    public void GetOSSdoesObjectExt(String str, int i) {
        String replaceAll;
        HiLog.e("" + i, 1, 0);
        if (i != 0) {
            this.mcumCounttry = 0;
        }
        if (this.mhiConfig != null) {
            HiLog.e("" + str + "::::" + this.isPlayStop, 1, 0);
            if (i != 0) {
                if (str != null) {
                    this.mhiConfig.setOSS_objectKey(str);
                } else {
                    HiConfig hiConfig = this.mhiConfig;
                    hiConfig.setOSS_objectKey(hiConfig.getOSS_UUID());
                }
            }
            if (this.mIsOCloud) {
                int indexOf = this.mhiConfig.getOSS_objectKey().indexOf(Const.Config.DB_NAME_SUFFIX);
                String bucket_name = this.mhiConfig.getBUCKET_NAME();
                HiLog.e(indexOf + ":::" + bucket_name, 1, 0);
                if (indexOf > 0) {
                    replaceAll = bucket_name.replaceAll("-rec", "-db");
                } else {
                    replaceAll = bucket_name.replaceAll("-db", "-rec");
                }
                this.mhiConfig.setBUCKET_NAME(replaceAll);
            }
            HiLog.e(this.mhiConfig.getOSS_ENDPOINT(), 1, 0);
            HiLog.e(this.mhiConfig.getBUCKET_NAME(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_ID(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_KEY_SECRET(), 1, 0);
            HiLog.e(this.mhiConfig.getOSS_ACCESS_TOKEN(), 1, 0);
            if (System.currentTimeMillis() - this.mSaveOssGetTime > 3600000 - this.mSetOsstime) {
                if (this.mIsOCloud) {
                    Timer timer = this.mUidEXIPREtimer;
                    if (timer != null) {
                        timer.cancel();
                    }
                    this.mUidEXIPREtimer = null;
                    this.mhiCloudsdk.HiCloudSDKgetOCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                } else {
                    this.mhiCloudsdk.HiCloudSDKgetCloudinfo(this, 0, this.mhiConfig.getOSS_UUID(), this.mhiCloudname, this.mhiCloudpwd, this.mhiCloudKey, this.mhiCloudSer, this.mhiCloudport, (short) 5);
                }
                this.mOssOperation = 6;
                return;
            }
            ThreadOSSdoesobj threadOSSdoesobj = this.mthreadossdoesobj;
            if (threadOSSdoesobj != null) {
                threadOSSdoesobj.weakup();
                this.mthreadossdoesobj.stopThread();
                this.mthreadossdoesobj = null;
            }
            if (this.mthreadossdoesobj == null) {
                ThreadOSSdoesobj threadOSSdoesobj2 = new ThreadOSSdoesobj();
                this.mthreadossdoesobj = threadOSSdoesobj2;
                threadOSSdoesobj2.startThread();
            }
        }
    }
}