• <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
            <2015年6月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(34)

            隨筆分類

            隨筆檔案

            文章檔案

            相冊

            收藏夾

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            SIP

            先說下網絡開源的sip產品:

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


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


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


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


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

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

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

               

            ios4及之后

            1)請求后臺任務 (600s 以內)beginBackgroundTaskWithExpirationHandler ^{} 


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

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

                       按鎖屏鍵后,ios6及之前會活躍來執行代碼,但是在ios7中,后臺任務處理方式發生改變,鎖屏后后臺任務暫時暫停已節省電力,之后在特定時間如檢查郵件或接電話時,之前暫停的后臺任務一起執行,就是說,系統不會專門為第三方應用保存設備處于活動狀態。

             


                用法:

            [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';">重要任務 當然,這時app運行著,可以繼續執行任何之前正在執行的代碼  所有有時候重要任務只是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;">//當系統后臺時間即將結束的時候</span>,系統會運行這個代碼結束,否則app不是緩存到內存,而是直接殺死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>//當然,你可以繼續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);">//就算被殺死,調用</span></span></span><span style="font-family: Menlo;">applicationWillTerminate繼續執行 5s 來保存數據</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切后臺執行,殺死并不執行</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在后臺每隔一段時間執行一下 (600s 以外)  setKeepAliveTimeout : time  handler : ^{} 


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

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

             2)timeout必須>=600;

            3)喚醒app的時間間隔是不精準的;

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

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

            6)clearKeepAliveTimeout函數用來清除handler;

            用法:1)在info.plist里加入UIBackgroundModes鍵,其值為數組,數組之一為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之前,系統所接受的應用多任務可以大致分為幾種:


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

             

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

            • 改變了后臺任務的運行方式
            • 增加了后臺獲取(Background Fetch)
            • 增加了推送喚醒(靜默推送,Silent Remote Notifications)
            • 增加了后臺傳輸(?Background Transfer Service)
            1) 改變了后臺任務的運行方式 : 這個在上面有提到,ios7 鎖屏后 申請后臺任務后不是立馬運行
            @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) 評論(0)  編輯 收藏 引用
            亚洲人成网站999久久久综合 | 三级韩国一区久久二区综合 | 一本色道久久88综合日韩精品 | 国产精品久久久久久吹潮| 久久国产精品免费| 99久久婷婷国产一区二区| 99久久精品免费看国产| 亚洲国产成人精品女人久久久 | 国产精品久久国产精麻豆99网站| 波多野结衣AV无码久久一区| 亚洲精品无码成人片久久| 欧美丰满熟妇BBB久久久| 精品久久久久久无码国产| 国产精品一区二区久久精品涩爱 | 国产精品伦理久久久久久| 国产成人精品久久二区二区| 国产成人久久精品二区三区| 亚洲精品97久久中文字幕无码| 久久久国产一区二区三区| 久久有码中文字幕| 狠狠色婷婷久久一区二区三区| 精品久久久久久无码国产| 久久水蜜桃亚洲av无码精品麻豆| 99久久777色| A级毛片无码久久精品免费| 日本三级久久网| 久久97久久97精品免视看| 国产精品视频久久| 99精品久久精品| 91久久婷婷国产综合精品青草| 囯产精品久久久久久久久蜜桃| 久久国产高清一区二区三区| 国产精品成人99久久久久91gav| 国产Av激情久久无码天堂| 国产高潮国产高潮久久久| 国产精品久久久久aaaa| 久久丫精品国产亚洲av不卡| 久久久久亚洲AV无码麻豆| 久久国产精品一国产精品金尊| 国内精品伊人久久久久AV影院| 亚洲v国产v天堂a无码久久|