2016年6月6日 星期一

RTMP Spec 心得整理

本篇是讀完RTMP Specification 1.0 後的心得整理。會以 spec為主並搭配 wireshark  rtmp_sample 封包為例,介紹一個基本的 RTMP 播放流程。

2016年6月3日 星期五

[Embedded] 檢視 message queue 資訊

Linux 下的 IPC 運作若使用 message queue,有兩種 message queue 可用,分別是 SYSTEM V MESSAGE QUEUE 與 POSSIX MESSAGE QUEUE,本篇將介紹如何確認 message queue 中的資訊。

2016年6月1日 星期三

使用 wireshark 的 lua script

Wireshark 支援 lua script ,可以讓我們自行撰寫需要的 disector,簡單的說就是可以讓我自行定義封包要怎麼切割以及顯示。這是個非常有用的功能。

本次練習的環境為
  • OS X EI  Capitan v10.11.3 64bit
  • wireshark 2.0.2 64bit

[Study] Google必修的圖表簡報術

本書作者 Cole Nussbaumer Knaflic 曾任Google人力分析團隊總監,她從心理學的角度介紹設計簡報的一些技巧。推薦大家應該看一下。摘要閱讀心得如下:

2016年4月10日 星期日

Online Password Digest of WSS v1.1 Username Token Profile

The WSS 1.1 Username Token Profile allows digest passwords to be sent in a wsse:UsernameToken of a SOAP message. The formula is
Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )
Below list 2 test vector
Test Vector 1
Nonce : juVKtZ22NkCZfPadWjVAs2UAAAAAAA==
created: 2016-03-24T06:16:28.732Z
password = 1234
PasswordDigest: oXq1ma7BR1vYdHBW01Hn1Aa1ppQ=
Test Vector 2
Nonce : Mdr8Vh3rBzmt1s+3b+nvNJWIlKk=
created: 2016-03-12T11:54:16Z
password = 1234
PasswordDigest: s/bk3KbayLIJb4mK95+g+Feu7+Y=

You can use this form to check the correctness of your password digest.
nonce:       
created:     
password:
Reference:
  1. https://docs.oasis-open.org/wss/v1.1/wss-v1.1-spec-os-UsernameTokenProfile.pdf
  2. http://www.esqsoft.com/javascript_examples/date-to-epoch.htm
  3. https://blogs.oracle.com/ashutosh/entry/hash_password_support_and_token

2016年3月9日 星期三

iOS - Enable AirPlay for your APP

之前寫了一個簡單的音樂APP,可以在同時使用 AudioUnit 同時進行錄音與播放。使用手機測試錄音與播放是沒問題的,但是當我想要將程式改為在手機端錄音,透過 AirPlay 在電視上播放時卻發生問題,問題現象是手機上不會出現 AirPlay 選項。

以下記錄使用 Audio Unit 各種實驗與其結果:

1. 先了解 Audio 運作時可以設定的各種模式
摘錄 Apple 定義的 AudioSession Category/Mode 設定值 
Table B-1  Audio session category behavior
Category identifiers
Silenced by the Ring/Silent switch and by screen locking see note
Interrupts non-mixable apps audio
Allows audio input (recording) and output (playback)
AVAudioSessionCategoryAmbient
Yes
No
Output only
AVAudioSessionCategoryAudioProcessing
Yes
No input and no output
AVAudioSessionCategoryMultiRoute
No
Yes
Input and output
AVAudioSessionCategoryPlayAndRecord
No
Yes by default; no by using override switch
Input and output
AVAudioSessionCategoryPlayback
No
Yes by default; no by using override switch
Output only
AVAudioSessionCategoryRecord
No (recording continues with the screen locked)
Yes
Input only
AVAudioSessionCategorySoloAmbient
Yes
Yes
Output only
Table B-2  Modes and associated categories
Mode identifiers
Compatible categories
AVAudioSessionModeDefault
All
AVAudioSessionModeVoiceChat
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionModeGameChat
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionModeVideoRecording
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionCategoryRecord
AVAudioSessionModeMoviePlayback
AVAudioSessionCategoryPlayback
AVAudioSessionModeMeasurement
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionCategoryRecord
AVAudioSessionCategoryPlayback
AVAudioSessionModeVideoChat
AVAudioSessionCategoryPlayAndRecord
因為此 APP 同時有 Audio In/Audio Out,所以能夠選擇的設定如下
  • AVAudioSessionCategoryMultiRoute
  • AVAudioSessionCategoryPlayAndRecord
  • AVAudioSessionModeDefault
  • AVAudioSessionModeVoiceChat
  • AVAudioSessionModeGameChat
  • AVAudioSessionModeVideoRecording
  • AVAudioSessionModeMeasurement
  • AVAudioSessionModeVideoChat

2. 測試不同 Audio Session Mode 與 Audio Unit 同時啟用時所造成的影響
以下僅為個人實驗結果,當 APP 啟動後,若設定為下列 Category/Mode 不會出現 Airplay選項。
  • AVAudioSessionCategoryMultiRoute
  • AVAudioSessionCategoryPlayAndRecord
  • AVAudioSessionModeGameChat
  • AVAudioSessionModeVideoRecording
  • AVAudioSessionModeVoiceChat

圖例如下:


當 APP 啟動後,若設定為下列 Category/Mode 可以出現 Airplay選項。
  • AVAudioSessionModeDefault
  • AVAudioSessionModeMeasurement
  • AVAudioSessionModeVideoChat

此時已經可以正常播放音樂,圖例如下:
 
但是一旦當APP開始進行錄音時,卻會變成只有 "iPhone" 與 "iPhone擴音"可選
圖例如下:


設定方式舉例如下: 
[[sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionMixWithOthers error:&setCategoryErr];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionModeDefault error:&setCategoryErr]; 
經過上述實驗,我會懷疑是否使用Audio Unit 進行錄音時,便無法使用Airplay。


3. 設定 APP Capabilities,設定 Background Modes 支援 Audio and Airplay,如下圖:
此作法也是沒用。


結論:本來想作好此功能之後,可以把家裡電視跟舊iPhone結合成卡拉OK,沒想到一直試不出來,只好作罷。如果有好心人試出這個功能,麻煩請教教我啊,謝謝。

參考資料
  1. Audio Session Categories and Modes
  2. Jawbone/AudioSessionManager 
  3. AudioSessionProgrammingGuide
  4. EnrichYourAppforAirPlay


[Embedded] how to check heap corruption

上週的 linux news 提到 iOS 上的一個問題,Analysis of iOS & OS X Vulnerability: CVE-2016-1722,指出了 heap overflow 的問題。這篇新聞提醒了自己,應該要將之前的實戰經驗做一下整理了。本篇會針對如何找到 heap corruption 的方法作一整理。