xcode でビルドした ios/mac アプリから AppRTCDemo 以外のことを wbertc で通信する
例えば、mac 用にビルドした AppRTCDemo は今のところ映像の受信は出来るが、送信のコードは組み込まれていない。
なので例えばそれを実現するためには ios の際に利用する RTCAVFoundationVideoSource.h のようなコードを自前で書く必用がある。
環境
- osx 10.10.3
- xcode 6.3.2
- webrtc の revision b444b3f0ff095fce497c403aa8149f15ce2f3ea9
- chrome 43.0.2357.81
webrtc の build, xcode の設定
- mac app から webrtc の DataChannel でやりとりをする - @soh335 memo
- /path/to/webrtc/src/ を header search path に追加
- macro に
WEBRTC_POSIX=1 WEBRTC_MAC=1
を追加 ( mac の場合 ) - runtime types を no
- libstdc++ にする
RTCAVFoundationVideoSource.h のようなものを書く
- 今回だと objc++ を書く必用がある
ジェームス・ブラウン 最高の魂を持つ男
ライブシーン迫力ある
小林カツ代と栗原はるみ 料理研究家とその時代
- 作者: 阿古真理
- 出版社/メーカー: 新潮社
- 発売日: 2015/05/16
- メディア: 新書
- この商品を含むブログ (4件) を見る
あとがきに
サブタイトルにもある通り、本書は料理研究家とその時代を研究した本である。しかし、執筆を進めるうちに女性史としての側面が思いの外強くなった。長年、家庭料理の狙いては当然女性、と思われてきたからである。ここ数年、「料理=愛情」という表現が目立つのは、その前提が崩れてきたからだろう。料理は誰がするべきか―その問題を考える機会にもなった
とあるとおり、思ってた以上に女性史の話が占める割合が多かった。普段読まない内容なので、それはそれで良かったとした。
予告犯
原作は未読。ストーリが少しチープすぎるかなと感じた。 同じ監督の白ゆき姫殺人事件もネットの扱いの点でいまいちだったので相性の可能性もある。(アヒルと鴨のコインロッカーとか、奇跡のリンゴは良かった)
mac app から webrtc の DataChannel でやりとりをする
環境
- osx 10.10.3
- xcode 6.3.2
- webrtc の revision b444b3f0ff095fce497c403aa8149f15ce2f3ea9
- chrome 43.0.2357.81
webrtc を build する
- iOS - WebRTC の通りに build する。
- How to get started with WebRTC and iOS without wasting 10 hours of your life | Ninjanetic Design を参考に libtool を使ってまとめたりする。
xcode の設定
- 上の記事を参考に必用なライブラリ、framework を追加する
src/talk/app/webrtc/objc/public/*.h"
の header を見れるようにする- 下の sample は swift なので Objective-C Bridging Header に指定したファイルに上の header をひと通り import する ( RTCEAGLVideoView.h は ios 用 )
Demo App
src/talk/examples/objc/AppRTCDemo
にサンプルアプリのコードがある
DataChannel を使う
長いので mac app 側から繋ぐ時に必用なところを抜粋する。
RTCPeerConnectionFactory.initializeSSL()
を最初に呼んでおく必用がある。
接続を開始する
let ices = [ RTCICEServer(URI: NSURL(string: "stun:stun.l.google.com:19302")!, username: "", password: ""), ] let optional = [ RTCPair(key: "DtlsSrtpKeyAgreement", value: "true") ] conn = factory.peerConnectionWithICEServers( ices, constraints: RTCMediaConstraints(mandatoryConstraints: [], optionalConstraints: optional), delegate: self ) let channelinit = RTCDataChannelInit() datachannel = conn.createDataChannelWithLabel("...", config: channelinit) datachannel.delegate = self conn.createOfferWithDelegate( self, constraints: RTCMediaConstraints(mandatoryConstraints: [ RTCPair(key: "OfferToReceiveAudio", value: "false"), RTCPair(key: "OfferToReceiveVideo", value: "false") ], optionalConstraints: nil) )
RTCSessionDescriptionDelegate
func peerConnection(peerConnection: RTCPeerConnection!, didCreateSessionDescription sdp: RTCSessionDescription!, error: NSError!) { dispatch_async(dispatch_get_main_queue(), { if error != nil { // err return } peerConnection.setLocalDescriptionWithDelegate(weakSelf, sessionDescription: sdp) // send sdp to signaling server }) }
RTCPeerConnectionDelegate
func peerConnection(peerConnection: RTCPeerConnection!, gotICECandidate candidate: RTCICECandidate!) { dispatch_async(dispatch_get_main_queue(), { // send candidate to signaling server }) }
Signaling Server からのデータの受信
func receiveMessage(msg SignalMessage) { switch msg.type { case .Anseer: let sessionDescription = RTCSessionDescription(type: msg.answer.type, sdp: msg.answer.sdp) conn.setRemoteDescriptionWithDelegate(self, sessionDescription: sessionDescription) case .ICE let candidate = RTCICECandidate(mid: msg.candidate.mid, index: msg.candidate.index, sdp: msg.candidate.sdp) conn.addICECandidate(candidate) default: break } }
Data Channel 経由で書き込みを行う
let data = "...".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! let buf = RTCDataBuffer(data: data, isBinary: false) datachannel.sendData(buf)
RTCDataChannelDelegate
func channel(channel: RTCDataChannel!, didReceiveMessageWithBuffer buffer: RTCDataBuffer!) { if buffer.isBinary { return } let str = NSString(data: buffer.data, encoding: NSUTF8StringEncoding) println(str) }
それでも町は廻っている 14巻
- 作者: 石黒正数
- 出版社/メーカー: 少年画報社
- 発売日: 2015/05/30
- メディア: コミック
- この商品を含むブログ (17件) を見る
とにかく面白い
少女ファイト(12)
- 作者: 日本橋ヨヲコ,木内亨
- 出版社/メーカー: 講談社
- 発売日: 2015/05/22
- メディア: コミック
- この商品を含むブログ (8件) を見る
最高に面白い