為了實現dm365中 write 子線程能夠向 live555的doGetNextFrame( ) 傳遞 NALU 。
dm365中的 encode 程式是基於多線程的,而 live555 是基於 select 查詢機制的,為了實現 encode 後的資料傳入 live555,並經由 live555 封裝 RTP 包發送。實現資料的互動,這成為了自己需要思考的問題。
在《嵌入式即時資料流媒體伺服器的實現》這篇論文中看到了 Unix_domain_socket 這個東西,作者用它實現了 2 個進程之間的資料傳遞,情況和我目前遇到的有些相似。
****************************************************************華麗的分割線*************************************************************
http://en.wikipedia.org/wiki/Unix_domain_socket
A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for
exchanging data between processes executing within the same host operating system. While similar in functionality tonamed pipes, Unix domain sockets may be created asbyte
streams or asdatagram sequences, while pipes are byte streams only. Processes using Unix domain sockets do not need to share a common ancestry. TheAPI
for Unix domain sockets is similar to that of anInternet socket, but does not use an underlying network protocol for communication. The Unix domain socket
facility is a standard component ofPOSIXoperating systems.
Unix domain sockets use the file system as address
name space. They are referenced by processes as
inodes in the file system. This allows two processes to open the same socket in order to communicate. However, communication occurs entirely within the operating system kernel.
In addition to sending data, processes may send
file descriptors across a Unix domain socket connection using the sendmsg() andrecvmsg() system calls.
****************************************************************華麗的分割線*************************************************************
(現在的時間是2012-06-03周日下午15:16)
對於Unix Domain Socket,我的理解是,它利用通訊端實現了Unix下的進程之間的通訊,而這種通訊方式類似於管道通訊,但是,這種通訊方式是可以實現雙向全雙工系統通訊,並且不涉及網路通訊協定棧之類的底層的東西,所以我認為它不會有拆包這種煩人的東西。
目前,我的方法是,在 live555 的 doGetNextFrame( ) 中建立 Unix Domain Socket 通訊端,並將該 socket 加入到 live555 的 select 查詢機制中(等待該 socket 可讀時,判斷是否是 dm365 回送的 NALU 資料),然後向 dm365 的 write 線程發送 NALU請求訊息。在 dm365 開發板中的 write 線程中,採用了 select + NonBlocking 機制,偵聽是否有從 live555 發來的 NALU
請求資訊,如果有,則在 write 線程中等待一個完整的 NALU ,然後發送給 live555。