Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

后续Server端是否会更新下音频相关的的例子呢,比如AAC的? #2

Open
wusopp opened this issue Nov 1, 2019 · 3 comments

Comments

@wusopp
Copy link

wusopp commented Nov 1, 2019

如题,后续Server端是否会更新下音频相关的的例子呢,比如AAC的

@PHZ76
Copy link
Owner

PHZ76 commented Nov 1, 2019

你好,这个可以同时推流H.264和AAC,可以参考这个 https://github.com/PHZ76/DesktopSharing

@wusopp
Copy link
Author

wusopp commented Nov 1, 2019

你好,这个可以同时推流H.264和AAC,可以参考这个 https://github.com/PHZ76/DesktopSharing

感谢回复,我这边还有个语法上的问题向你请教下:
就是addTriggerEvent 触发事件的使用场景问题,比如rtmp publish中,使用handshake完成握手。如下所示:
m_taskScheduler->addTriggerEvent(this{
m_rtmpConn->handshake();
});
在rtsp server 代码中也使用此类触发事件完成channel 的增加和删除,但我看rtmp server代码中有的地方注释掉了addTriggerEvent,比如

  //m_taskScheduler->addTriggerEvent([=]() {
m_rtmpConn->sendAudioData(timestamp, payload, payloadSize);
    //});

   我实际注释掉了握手部分的addTriggerEvent,如下所示,也是可以运行的。并在源码中实现时是采用将回调函数压栈,然后通过lambda表达式的方式进行事件触发。貌似不压栈也可以?
    //m_taskScheduler->addTriggerEvent([this](){
	m_rtmpConn->handshake();
//});
 所以向你请教下,TriggerEvent使用场景是什么时候呢?为什么有的地方适合调用这个函数,有的地方不适用,需要注释掉呢?

@PHZ76
Copy link
Owner

PHZ76 commented Nov 1, 2019

因为调用pushAudioFrame的线程 和 EventLoop的事件处理线程 不是同一个线程, addTriggerEvent 是为了线程安全,作用是投递事件到EventLoop的线程。这边改为在内部调用了,所以上面那里注释掉了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants