• <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
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(34)

            隨筆分類(lèi)

            隨筆檔案

            文章檔案

            相冊(cè)

            收藏夾

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            SIP

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

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


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


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


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


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

               

            ios4及之后

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


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

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

                       按鎖屏鍵后,ios6及之前會(huì)活躍來(lái)執(zhí)行代碼,但是在ios7中,后臺(tái)任務(wù)處理方式發(fā)生改變,鎖屏后后臺(tái)任務(wù)暫時(shí)暫停已節(jié)省電力,之后在特定時(shí)間如檢查郵件或接電話時(shí),之前暫停的后臺(tái)任務(wù)一起執(zhí)行,就是說(shuō),系統(tǒng)不會(huì)專(zhuān)門(mén)為第三方應(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>來(lái)請(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);">//如果沒(méi)有這句,會(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來(lái)獲取剩余時(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 來(lái)保存數(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秒類(lèi)執(zhí)行完。10秒后app再次被阻塞。(可以         用-backgroundTimeRemaining屬性來(lái)查看返回剩余時(shí)間);

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

            6)clearKeepAliveTimeout函數(shù)用來(lái)清除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)播放音樂(lè)等
            • 位置服務(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://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
            posted on 2016-11-04 18:05 聶文龍 閱讀(291) 評(píng)論(0)  編輯 收藏 引用

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


            亚洲国产高清精品线久久| 国产精品久久久久久搜索| 久久人人爽人爽人人爽av| 久久久久亚洲AV成人网人人软件| 国产精品99久久精品爆乳| 老男人久久青草av高清| 国产Av激情久久无码天堂| 久久久无码精品亚洲日韩软件| 伊人久久无码精品中文字幕| 国产精品福利一区二区久久| 亚洲日本va午夜中文字幕久久 | 久久久久九九精品影院| 中文字幕无码精品亚洲资源网久久| 久久精品国产精品青草app| 久久天天躁夜夜躁狠狠躁2022| 97热久久免费频精品99| 中文字幕久久亚洲一区| 香蕉久久夜色精品国产小说| 人妻少妇久久中文字幕一区二区| 久久久久亚洲av毛片大| 国产L精品国产亚洲区久久| 无码精品久久久久久人妻中字| 深夜久久AAAAA级毛片免费看 | 人妻精品久久久久中文字幕69| 久久99国产精品成人欧美| 2021精品国产综合久久| 久久久亚洲欧洲日产国码aⅴ | 久久AⅤ人妻少妇嫩草影院| 国产精品对白刺激久久久| 久久精品青青草原伊人| 亚洲精品tv久久久久| 久久AⅤ人妻少妇嫩草影院| 伊人久久综在合线亚洲2019| 久久久久夜夜夜精品国产| 久久久精品人妻一区二区三区蜜桃 | 国产成人久久精品一区二区三区| 四虎国产精品成人免费久久| 综合久久给合久久狠狠狠97色| 欧美麻豆久久久久久中文| 色妞色综合久久夜夜| 久久久SS麻豆欧美国产日韩|