• <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
            <2007年6月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(34)

            隨筆分類

            隨筆檔案

            文章檔案

            相冊

            收藏夾

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            SIP

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

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


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


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


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


            雜談   一一   ios4之后 和  ios7新增 的后臺部分知識:

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

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

               

            ios4及之后

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


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

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

                       按鎖屏鍵后,ios6及之前會活躍來執(zhí)行代碼,但是在ios7中,后臺任務(wù)處理方式發(fā)生改變,鎖屏后后臺任務(wù)暫時暫停已節(jié)省電力,之后在特定時間如檢查郵件或接電話時,之前暫停的后臺任務(wù)一起執(zhí)行,就是說,系統(tǒng)不會專門為第三方應(yīng)用保存設(shè)備處于活動狀態(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)然,這時app運行著,可以繼續(xù)執(zhí)行任何之前正在執(zhí)行的代碼  所有有時候重要任務(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>來請求時間運行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);">//如果沒有這句,會</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)后臺時間即將結(jié)束的時候</span>,系統(tǒng)會運行這個代碼結(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來獲取剩余時間</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切后臺執(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在后臺每隔一段時間執(zhí)行一下 (600s 以外)  setKeepAliveTimeout : time  handler : ^{} 


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

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

             2)timeout必須>=600;

            3)喚醒app的時間間隔是不精準(zhǔn)的;

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

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

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

            用法:1)在info.plist里加入UIBackgroundModes鍵,其值為數(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 新增的后臺功能

            前言:

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


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

             

            iOS7后臺的變化在于以下四點:

            • 改變了后臺任務(wù)的運行方式
            • 增加了后臺獲取(Background Fetch)
            • 增加了推送喚醒(靜默推送,Silent Remote Notifications)
            • 增加了后臺傳輸(?Background Transfer Service)
            1) 改變了后臺任務(wù)的運行方式 : 這個在上面有提到,ios7 鎖屏后 申請后臺任務(wù)后不是立馬運行
            @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 聶文龍 閱讀(301) 評論(0)  編輯 收藏 引用

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


            久久精品国产亚洲AV无码麻豆| 久久精品18| 伊人热热久久原色播放www| 久久最新免费视频| 精品国产99久久久久久麻豆| 少妇高潮惨叫久久久久久| 久久久av波多野一区二区| 青青草原1769久久免费播放| 久久久久久国产精品无码下载| 人妻系列无码专区久久五月天| 亚洲精品无码专区久久久| 国产精品熟女福利久久AV| 亚洲午夜无码久久久久| 狠狠色综合久久久久尤物| 亚洲AV无一区二区三区久久| 亚洲国产成人久久精品影视| 精品久久久久久国产| 久久无码人妻精品一区二区三区| 亚洲成色www久久网站夜月| 国产日韩久久免费影院| 久久久亚洲欧洲日产国码二区| 精品久久久久久99人妻| 久久久久人妻一区精品性色av| 亚洲精品无码久久久| 免费观看成人久久网免费观看| 午夜久久久久久禁播电影| 久久毛片免费看一区二区三区| 狠狠色丁香婷婷综合久久来| 久久伊人精品一区二区三区| 久久久精品无码专区不卡| 久久国产免费观看精品| 日产精品久久久久久久| 久久综合亚洲鲁鲁五月天| 久久噜噜久久久精品66| 国产精品久久久久久久午夜片 | 国产精品一区二区久久不卡| 一级做a爰片久久毛片毛片| 久久男人中文字幕资源站| 99久久综合国产精品二区| 91精品国产高清久久久久久国产嫩草| 99久久人妻无码精品系列蜜桃|