• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 298  文章 - 377  trackbacks - 0
            <2017年8月>
            303112345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            常用鏈接

            留言簿(34)

            隨筆分類

            隨筆檔案

            文章檔案

            相冊(cè)

            收藏夾

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            SIP

            先說下網(wǎng)絡(luò)開源的sip產(chǎn)品:

            1)PJSIP   這是一個(gè)開源庫,研究的不多,因?yàn)闆]有那個(gè)時(shí)間去重最基本的區(qū)開發(fā),畢竟不是專門做這方面的,所以直接去找做好的開源產(chǎn)品。


            2)linphone    這是我最開始找到的開源產(chǎn)品,網(wǎng)上推薦率很高,音質(zhì)十分清晰,適合做點(diǎn)對(duì)點(diǎn)語音,但是開始著手的時(shí)候遇到兩個(gè)問題,一 是國外資源封殺的厲害,資源十分難下載; 二 是其編譯實(shí)在麻煩,下了一堆庫和編譯環(huán)境,完全按照官網(wǎng)的步驟,發(fā)現(xiàn)還是有些地方編譯不過,在linphone上的編譯上就耗了我一周時(shí)間,最主要的還是網(wǎng)絡(luò)限制,大部分編譯環(huán)境和工具都得在國外網(wǎng)站下載,耗了比較多時(shí)間,一周之后,我果斷放棄linphone,繼續(xù)找其他開源產(chǎn)品。


            3)siphon       在陸續(xù)找到很多開源sip產(chǎn)品后,最后選擇了siphon;兩個(gè)原因, 一  比較好編譯  二  音質(zhì)還不錯(cuò),這個(gè)軟件基本的帶電話和接電話功能,不過經(jīng)過使用發(fā)現(xiàn)其沒有后臺(tái)接電話功能,最扯是我快弄完的時(shí)候才發(fā)現(xiàn)沒有后臺(tái)。后臺(tái)部分下面后說到,這里只列舉下我遇到的開源sip產(chǎn)品。


            4)idoubs      這個(gè)就牛B了,這是在我發(fā)現(xiàn)siphon沒有后臺(tái)后,在經(jīng)過網(wǎng)上各種說如何實(shí)現(xiàn)VIOP后臺(tái)的帖子折磨后找到的一個(gè)開源軟件,音質(zhì)和linphone不相上下,且實(shí)現(xiàn)點(diǎn)對(duì)點(diǎn)視頻功能,可以說滿足了大部分人得需求了,編譯也十分簡(jiǎn)單,按官網(wǎng)步驟走即可,兩個(gè)文件夾,一個(gè)doubango庫,這是基礎(chǔ)庫,很好的封裝了sip電話的各種功能,比較大,大概850M;一個(gè)是idoubs,這個(gè)實(shí)現(xiàn)了sip電話的UI部分,這個(gè)才23M。這個(gè)最重要的是實(shí)現(xiàn)了后臺(tái)運(yùn)行和接電話功能,就是可以home鍵切出后可以有來電提醒,不過這個(gè)和網(wǎng)上說的利用  TCP+socket 來實(shí)現(xiàn)后臺(tái)不同的是,這是利用后臺(tái)播放靜默音樂來實(shí)現(xiàn),后臺(tái)部分也有些bug,如 接真實(shí)電話、音樂播放軟件后臺(tái)播放和暫停、微信的語音播放都會(huì)打斷這個(gè)靜默音樂的播放,導(dǎo)致后臺(tái)失敗,破解方法后面會(huì)說到。


            雜談   一一   ios4之后 和  ios7新增 的后臺(tái)部分知識(shí):

            前言:iOS不是真正的多任務(wù)系統(tǒng),在用戶按下Home按鈕后,所有應(yīng)用程序都會(huì)進(jìn)入后臺(tái)狀態(tài),并且大部分都會(huì)迅速進(jìn)入暫停狀態(tài),應(yīng)用程序的所有工作內(nèi)存都在RAM中,在暫停時(shí)它完全不執(zhí)行。因此,切換回這樣的應(yīng)用程序非常快。但是如果系統(tǒng)需要更多的內(nèi)存給當(dāng)前處于活動(dòng)狀態(tài)的應(yīng)用程序,就有可能終結(jié)暫停狀態(tài)的應(yīng)用程序,它們的內(nèi)存也將被釋放。

            一方面,應(yīng)用程序在進(jìn)入后臺(tái)狀態(tài)時(shí),需要釋放一些資源,使自身的暫停快照更小,從而減少從RAM中清除的風(fēng)險(xiǎn),另一方面,為了避免被終結(jié)而丟失用戶的數(shù)據(jù),需要在用戶離開時(shí)保存他們的進(jìn)度信息,這些工作,需要在5秒鐘內(nèi)完成,不然會(huì)被系統(tǒng)認(rèn)定有異常被強(qiáng)制退出。可能通過接收應(yīng)用程序發(fā)送的通知

               

            ios4及之后

            1)請(qǐng)求后臺(tái)任務(wù) (600s 以內(nèi))beginBackgroundTaskWithExpirationHandler ^{} 


            作用 :  可以切后臺(tái)后進(jìn)行一些未完成的下載和比較重要的事情,如短時(shí)間的下載,消息的發(fā)送,未完成的上傳,反正在600s內(nèi)app可以做任何事情。

               注意:按home鍵后,會(huì)運(yùn)行一段時(shí)間來執(zhí)行代碼,如無代碼,3分鐘左右執(zhí)行block。

                       按鎖屏鍵后,ios6及之前會(huì)活躍來執(zhí)行代碼,但是在ios7中,后臺(tái)任務(wù)處理方式發(fā)生改變,鎖屏后后臺(tái)任務(wù)暫時(shí)暫停已節(jié)省電力,之后在特定時(shí)間如檢查郵件或接電話時(shí),之前暫停的后臺(tái)任務(wù)一起執(zhí)行,就是說,系統(tǒng)不會(huì)專門為第三方應(yīng)用保存設(shè)備處于活動(dòng)狀態(tài)。

             


                用法:

            [objc] view plain copy
            1. <p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">- (<span style="color: #35568a">void</span>) doUpdate</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">{</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: #000000">    [</span><span style="color: #35568a">self</span><span style="color: #000000"> </span>beginBackgroundUpdateTask<span style="color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; min-height: 21px;">    </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(207, 135, 36);"><span style="color: #000000">    </span>//<span style="font-family: 'Heiti SC Light';">重要任務(wù) 當(dāng)然,這時(shí)app運(yùn)行著,可以繼續(xù)執(zhí)行任何之前正在執(zhí)行的代碼  所有有時(shí)候重要任務(wù)只是sleep()<span style="white-space:pre">  </span>         <span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);">//</span>來請(qǐng)求時(shí)間運(yùn)行app</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(195, 89, 0);"><span style="color: #000000">    </span>NSURLRequest<span style="color: #000000"> *request = [[</span>NSURLRequest<span style="color: #000000"> </span><span style="color: #587ea8">alloc</span><span style="color: #000000">]</span><span style="color: #587ea8">initWithURL</span><span style="color: #000000">:[</span>NSURL<span style="color: #000000"> </span><span style="color: #587ea8">URLWithString</span><span style="color: #000000">:</span><span style="color: #e82300">@"xxx"</span><span style="color: #000000">]];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">    <span style="color: #c35900">NSURLResponse</span> * response = <span style="color: #35568a">nil</span>;</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">    <span style="color: #c35900">NSError</span>  * error = <span style="color: #35568a">nil</span>;</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">    <span style="color: #c35900">NSData</span> * responseData = [<span style="color: #c35900">NSURLConnection</span> <span style="color: #587ea8">sendSynchronousRequest</span>: request <span style="color: #587ea8">returningResponse</span>: &response <span style="color: #587ea8">error</span>: &error];</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; min-height: 21px;">    </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(207, 135, 36);"><span style="color: #000000">    </span>// Do something with the result</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; min-height: 21px;">    <span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);">//如果沒有這句,會(huì)</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: #000000">    [</span><span style="color: #35568a">self</span><span style="color: #000000"> </span>endBackgroundUpdateTask<span style="color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">}</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; min-height: 21px;">  
            2. </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">- (<span style="color: #35568a">void</span>) beginBackgroundUpdateTask</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">{</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: #000000">    </span><span style="color: #35568a">self</span><span style="color: #000000">.</span>backgroundUpdateTask<span style="color: #000000"> = [[</span><span style="color: #c35900">UIApplication</span><span style="color: #000000"> </span>sharedApplication<span style="color: #000000">] </span>beginBackgroundTaskWithExpirationHandler<span style="color: #000000">:^{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: 'Heiti SC Light'; color: rgb(207, 135, 36);"><span style="font-family: Menlo; color: rgb(0, 0, 0);">        </span><span style="font-family: Menlo;">//當(dāng)系統(tǒng)后臺(tái)時(shí)間即將結(jié)束的時(shí)候</span>,系統(tǒng)會(huì)運(yùn)行這個(gè)代碼結(jié)束,否則app不是緩存到內(nèi)存,而是直接殺死app</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: 'Heiti SC Light'; color: rgb(207, 135, 36);"><span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);"><span style="white-space:pre">   </span>//當(dāng)然,你可以繼續(xù)backgroundTimeRemaining來獲取剩余時(shí)間</span>  
            3. </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: 'Heiti SC Light'; color: rgb(207, 135, 36);"><span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);"><span style="white-space:pre">   <span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);">//就算被殺死,調(diào)用</span></span></span><span style="font-family: Menlo;">applicationWillTerminate繼續(xù)執(zhí)行 5s 來保存數(shù)據(jù)</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: 'Heiti SC Light'; color: rgb(207, 135, 36);"><span style="font-family: Menlo;"><span style="white-space:pre">    <span style="color: rgb(207, 135, 36); font-family: Menlo; font-size: 18px; white-space: pre; background-color: rgb(240, 240, 240);">//</span></span></span><span style="font-family: Menlo;">applicationDidEnterBackground 按home切后臺(tái)執(zhí)行,殺死并不執(zhí)行</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: rgb(0, 0, 0);">        [</span><span style="color: #35568a">self</span><span style="color: #000000"> </span>endBackgroundUpdateTask<span style="color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">    }];</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">}</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; min-height: 21px;">  
            4. </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">- (<span style="color: #35568a">void</span>) endBackgroundUpdateTask</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">{</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: #000000">    [[</span><span style="color: #c35900">UIApplication</span><span style="color: #000000"> </span>sharedApplication<span style="color: #000000">] </span>endBackgroundTask<span style="color: #000000">: </span><span style="color: #35568a">self</span><span style="color: #000000">.</span>backgroundUpdateTask<span style="color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo; color: rgb(88, 126, 168);"><span style="color: #000000">    </span><span style="color: #35568a">self</span><span style="color: #000000">.</span>backgroundUpdateTask<span style="color: #000000"> = </span>UIBackgroundTaskInvalid<span style="color: #000000">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: Menlo;">}</p><div>  
            5. </div>  


            2)iOS在后臺(tái)每隔一段時(shí)間執(zhí)行一下 (600s 以外)  setKeepAliveTimeout : time  handler : ^{} 


            作用:如app每隔一小時(shí)去刷新登錄的key值,避免key值失效。

            注意:1)要成功調(diào)用該函數(shù),就必須在Info.plist里設(shè)UIBackgroundModes鍵的array值之一voip字符串;

             2)timeout必須>=600;

            3)喚醒a(bǔ)pp的時(shí)間間隔是不精準(zhǔn)的;

            4)喚醒后只有10秒執(zhí)行時(shí)間。即handler里的代碼要在10秒類執(zhí)行完。10秒后app再次被阻塞。(可以         用-backgroundTimeRemaining屬性來查看返回剩余時(shí)間);

            5)該函數(shù)成功調(diào)用后,在程序生命周期內(nèi)有效,該函數(shù)的效果在回到前臺(tái)的狀況下,依然有效。(因此可以         把它當(dāng)timer使.) ;

            6)clearKeepAliveTimeout函數(shù)用來清除handler;

            用法:1)在info.plist里加入U(xiǎn)IBackgroundModes鍵,其值為數(shù)組,數(shù)組之一為voip字符串;

                 2)如下;

            [objc] view plain copy
            1. <p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px;">- (<span style="color: #35568a">void</span>) viewDidLoad</p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px;">{</p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px; color: rgb(88, 126, 168);"><span style="color: #000000">    [</span><span style="color: #35568a">super</span><span style="color: #000000"> </span>viewDidLoad<span style="color: #000000">];</span></p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px; color: rgb(207, 135, 36);">  
            2. </p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px; color: rgb(207, 135, 36);"><span style="color: #000000">    </span>//<span style="font-family: 'Heiti SC Light';">刷新</span>KEY</p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px; color: rgb(88, 126, 168);"><span style="color: #000000">    [[</span><span style="color: #c35900">UIApplication</span><span style="color: #000000"> </span>sharedApplication<span style="color: #000000">] </span>setKeepAliveTimeout<span style="color: #000000">:</span><span style="color: #35568a">1</span><span style="color: #000000">*</span><span style="color: #35568a">60</span><span style="color: #000000">*</span><span style="color: #35568a">60</span><span style="color: #000000"> </span>handler<span style="color: #000000">: ^{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; min-height: 21px;"><span style="font-family:Menlo;">        </span><span style="font-family: Menlo; color: rgb(207, 135, 36); font-size: 18px; line-height: 24px; white-space: pre; background-color: rgb(240, 240, 240);">//</span><span style="color: rgb(207, 135, 36); font-size: 18px; line-height: 24px; white-space: pre; background-color: rgb(240, 240, 240);"><span style="font-family:Heiti SC Light;">做一些你希望做的事情</span></span></p><p style="font-family: Menlo; margin-top: 0px; margin-bottom: 0px; font-size: 18px;">    }];</p><div style="font-family: Verdana, Arial, Helvetica, sans-serif;">}</div>  

            IOS7 新增的后臺(tái)功能

            前言:

            在iOS7之前,系統(tǒng)所接受的應(yīng)用多任務(wù)可以大致分為幾種:


            • 后臺(tái)完成某些花費(fèi)時(shí)間的特定任務(wù)
            • 后臺(tái)播放音樂等
            • 位置服務(wù)
            • IP電話(VoIP)
            • Newsstand

             

            iOS7后臺(tái)的變化在于以下四點(diǎn):

            • 改變了后臺(tái)任務(wù)的運(yùn)行方式
            • 增加了后臺(tái)獲取(Background Fetch)
            • 增加了推送喚醒(靜默推送,Silent Remote Notifications)
            • 增加了后臺(tái)傳輸(?Background Transfer Service)
            1) 改變了后臺(tái)任務(wù)的運(yùn)行方式 : 這個(gè)在上面有提到,ios7 鎖屏后 申請(qǐng)后臺(tái)任務(wù)后不是立馬運(yùn)行
            @import url(http://m.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
            posted on 2016-11-04 18:05 聶文龍 閱讀(295) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久精品波多野结衣| 久久91综合国产91久久精品| 99久久久精品| 久久国产精品二国产精品| 亚洲国产一成久久精品国产成人综合 | 久久影院综合精品| 天天爽天天爽天天片a久久网| 青青草国产精品久久久久| 亚洲国产精品无码久久九九| 久久亚洲国产成人精品性色| 国产成人久久精品麻豆一区 | 久久婷婷五月综合色高清| 久久高清一级毛片| 久久99国产精品尤物| 亚洲欧美日韩精品久久亚洲区| 久久人人爽人人爽人人AV | 色综合久久88色综合天天| 亚洲精品乱码久久久久久中文字幕| 麻豆精品久久久一区二区| 久久久一本精品99久久精品88| 99精品久久久久久久婷婷| 无码超乳爆乳中文字幕久久| 国产精品内射久久久久欢欢| 久久婷婷成人综合色综合| 久久久这里有精品| 久久精品无码一区二区app| 精品久久一区二区三区| 久久天天婷婷五月俺也去| 国内精品久久久久久中文字幕| 一级做a爰片久久毛片16| 久久国产精品-国产精品| 看久久久久久a级毛片| 狠狠色丁香久久婷婷综合| 久久久久久久91精品免费观看| 精品久久久久久无码人妻蜜桃| AA级片免费看视频久久| 国产99久久久久久免费看| 99热精品久久只有精品| 久久国产三级无码一区二区| 久久久久亚洲AV无码专区网站 | 久久精品蜜芽亚洲国产AV|