【发布时间】:2015-10-12 14:08:44
【问题描述】:
根据Native Client MediaStreamVideoTrack 的文档,有一个构造函数“构造一个 MediaStreamVideoTrack,将给定的帧输出到一个新的视频轨道,这将由 Javascript 使用。”
然后我的想法是将帧放入此视频轨道,稍后可以通过 javascript 在视频标签中显示或传递给 RTCPeerConnection。
我不知道这样做是否正确,但 PostMessage 的文档指出应该支持传递资源。但是使用下面的简单 Native Client 代码,我只会在浏览器控制台中收到警告:“无法将 PostMessage 参数从 PP_Var 转换为 Javascript 值。它可能有循环或属于不受支持的类型。”
virtual void HandleMessage(const pp::Var& var_message) {
if (!var_message.is_dictionary()) {
LogToConsole(PP_LOGLEVEL_ERROR, pp::Var("Invalid message!"));
return;
}
pp::VarDictionary var_dictionary_message(var_message);
std::string command = var_dictionary_message.Get("command").AsString();
if (command == "create_track") {
pp::MediaStreamVideoTrack video_track = pp::MediaStreamVideoTrack::MediaStreamVideoTrack(this);
pp::VarDictionary dictionary;
dictionary.Set(pp::Var("track"), pp::Var(video_track));
PostMessage(dictionary);
}
}
我做错了什么,还是不只是支持? :)
【问题讨论】: