Пример #1
0
 public static UploadVoiceContextMgr getInstance()
 {
     if (gUpVoiceContextMgr == null)
     {
         gUpVoiceContextMgr = new UploadVoiceContextMgr();
     }
     return(gUpVoiceContextMgr);
 }
Пример #2
0
//        public bool doSceneBegin(string toUserName)
//        {
//            if (UploadVoiceRecorder.isRunning())
//            {
//                Log.e("UploadVoiceService", "scene cannot begin in recording. ");
//                return false;
//            }
//            string hashString = MD5Core.GetHashString(toUserName + Util.getNowMilliseconds());
//            UploadVoiceContext context = UploadVoiceContext.createByClientMsgID(hashString);
//            if (context == null)
//            {
//                Log.e("UploadVoiceService", "create upload voice context failed. ");
//                return false;
//            }
//            Log.i("UploadVoiceService", "cmd to scene begin, toUserName = "******" , clientMsgId = " + hashString);
//            context.mUserName = toUserName;
//            context.mStatus = 0;
//            UploadVoiceContextMgr.getInstance().putToHead(context);
//            this.checkReadyContextDispatcher();
//            UploadVoiceRecorder.start(context);
//            return true;
//        }

        public bool doSceneDirectWithoutRecord(string toUserName, int voiceTimeLength, byte[] buffer, int EncodeType)
        {
            if (voiceTimeLength > 60)
            {
                voiceTimeLength = 60;
            }
            if (voiceTimeLength < 2)
            {
                voiceTimeLength = 2;
            }
            //voiceTimeLength = buffer.Length;
            voiceTimeLength *= 0x3e8;
            string             hashString = MD5Core.GetHashString(toUserName + Util.getNowMilliseconds());
            UploadVoiceContext context    = UploadVoiceContext.createByClientMsgID(hashString);

            if (context == null)
            {
                Log.e("UploadVoiceService", "create upload voice context failed. ");
                return(false);
            }
            Log.i("UploadVoiceService", "cmd to scene begin, toUserName = "******" , clientMsgId = " + hashString);
            //int count = (voiceTimeLength * 7) / 10;
            //byte[] buffer = new byte[count];
            //for (int i = 0; i < count; i++)
            //{
            //    buffer[i] = (byte) (i | 1);
            //}
            context.mCreateTime = (int)(Util.getNowMilliseconds() / 1000.0);
            context.mUserName   = toUserName;
            context.EncodeType  = EncodeType;//sikl
            context.appendOutputData(buffer, 0, buffer.Length);
            context.mVoiceTimeLength = voiceTimeLength;
            //context.
            context.mEndFlag = 1;
            context.mStatus  = 0;
            UploadVoiceContextMgr.getInstance().putToTail(context);
            this.checkReadyContextDispatcher();
            return(true);
        }
Пример #3
0
 public static void onVoiceContextDispatcher(object sender, EventArgs e)
 {
     UploadVoiceContextMgr.getInstance().clearnFinishedContext();
     if (UploadVoiceContextMgr.getInstance().getCount() <= 0)
     {
         //UploadVoiceContextLoader.checkCleanMsgTrans();
         if (UploadVoiceContextMgr.getInstance().getCount() <= 0)
         {
             closeDispatcherTimer();
             return;
         }
     }
     if (UploadVoiceContextMgr.getInstance().countRunningContext() < MAX_RUNNING)
     {
         UploadVoiceContext voiceContext = UploadVoiceContextMgr.getInstance().getFirstContextNeedHandle();
         if (voiceContext != null)
         {
             Log.i("UploadVoiceService", "new task startup, clientmsgid = " + voiceContext.mClientMsgId);
             NetSceneUploadVoice voice = new NetSceneUploadVoice();
             voice.mOnSceneFinished += new onSceneFinishedDelegate(UploadVoiceService.onSceneFinished);
             voice.doScene(voiceContext);
         }
     }
 }