2011-8-9 15:13:00
从媒体格式中获取port 且port必须是偶数
接着创建了一个数据包源 APacketSource
获取了pt,描述 和参数
getDurationUs
获取播放时间 以us为单位
如果从描述中设置为H.264
就设置MIME为 const char *MEDIA_MIMETYPE_VIDEO_AVC = "video/avc";
if (!sessionDesc->getDimensions(index, PT, &width, &height)) {
width = -1;
height = -1;
}
获取宽高 PT
ARTPConnection
现在看一下RTP连接是怎么回事?
struct ALooperRoster {
ALooperRoster();
ALooper::handler_id registerHandler(
const sp<ALooper> looper, const sp<AHandler> &handler);
void unregisterHandler(ALooper::handler_id handlerID);
void postMessage(const sp<AMessage> &msg, int64_t delayUs = 0);
void deliverMessage(const sp<AMessage> &msg);
sp<ALooper> findLooper(ALooper::handler_id handlerID);
private:
struct HandlerInfo {
wp<ALooper> mLooper;
wp<AHandler> mHandler;
};
Mutex mLock;
KeyedVector<ALooper::handler_id, HandlerInfo> mHandlers;
ALooper::handler_id mNextHandlerID;
DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster);
};
} // namespace android
这个是管理looper
ALooper::handler_id ALooperRoster::registerHandler(
const sp<ALooper> looper, const sp<AHandler> &handler) {
Mutex::Autolock autoLock(mLock);
if (handler->id() != 0) {
CHECK(!"A handler must only be registered once.");
return INVALID_OPERATION;
}
HandlerInfo info;
info.mLooper = looper;
info.mHandler = handler;
ALooper::handler_id handlerID = mNextHandlerID++;
mHandlers.add(handlerID, info);
handler->setID(handlerID);
return handlerID;
}
所有的looper 必须向looperRoast 注册
unregisterHandler 取消注册
void ALooperRoster::postMessage
根据消息的target找到对应的looper,然后调用looper的post方法
onMessageReceived
deliverMessage 是取的handler
findLooper 查找对应的loooper
runOnCallingThread 是否是在调用线程中运行?
如果不是就自己创建线程运行