|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include "QuicTransportStream.h" |
| 8 | +#include "../common/MediaFramePipelineWrapper.h" |
8 | 9 |
|
9 | 10 | using v8::Function; |
10 | 11 | using v8::FunctionTemplate; |
@@ -113,15 +114,32 @@ NAN_METHOD(QuicTransportStream::close) |
113 | 114 | NAN_METHOD(QuicTransportStream::addDestination) |
114 | 115 | { |
115 | 116 | QuicTransportStream* obj = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info.Holder()); |
116 | | - if (info.Length() != 2) { |
| 117 | + if (info.Length() > 3) { |
117 | 118 | Nan::ThrowTypeError("Invalid argument length for addDestination."); |
118 | 119 | return; |
119 | 120 | } |
120 | | - // TODO: Check if info[0] is an Nan wrapped object. |
121 | | - auto framePtr = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info[1]->ToObject()); |
122 | | - // void* ptr = info[0]->ToObject()->GetAlignedPointerFromInternalField(0); |
123 | | - // auto framePtr=static_cast<owt_base::FrameDestination*>(ptr); |
124 | | - obj->addDataDestination(framePtr); |
| 121 | + Nan::Utf8String param0(Nan::To<v8::String>(info[0]).ToLocalChecked()); |
| 122 | + std::string track = std::string(*param0); |
| 123 | + bool isNanDestination(false); |
| 124 | + if (info.Length() == 3) { |
| 125 | + isNanDestination = info[2]->ToBoolean(Nan::GetCurrentContext()).ToLocalChecked()->Value(); |
| 126 | + } |
| 127 | + owt_base::FrameDestination* dest(nullptr); |
| 128 | + if (isNanDestination) { |
| 129 | + NanFrameNode* param = Nan::ObjectWrap::Unwrap<NanFrameNode>(info[1]->ToObject()); |
| 130 | + dest = param->FrameDestination(); |
| 131 | + } else { |
| 132 | + ::FrameDestination* param = node::ObjectWrap::Unwrap<::FrameDestination>( |
| 133 | + info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked()); |
| 134 | + dest = param->dest; |
| 135 | + } |
| 136 | + if (track == "audio") { |
| 137 | + obj->addAudioDestination(dest); |
| 138 | + } else if (track == "video") { |
| 139 | + obj->addVideoDestination(dest); |
| 140 | + } else if (track == "data") { |
| 141 | + obj->addDataDestination(dest); |
| 142 | + } |
125 | 143 | obj->m_isPiped = true; |
126 | 144 | } |
127 | 145 |
|
@@ -153,6 +171,12 @@ void QuicTransportStream::MaybeReadContentSessionId() |
153 | 171 | m_receivedContentSessionId = true; |
154 | 172 | m_asyncOnContentSessionId.data = this; |
155 | 173 | uv_async_send(&m_asyncOnContentSessionId); |
| 174 | + for (uint8_t d : m_contentSessionId) { |
| 175 | + if (d != 0) { |
| 176 | + m_isPiped = true; |
| 177 | + break; |
| 178 | + } |
| 179 | + } |
156 | 180 | if (m_stream->ReadableBytes() > 0) { |
157 | 181 | SignalOnData(); |
158 | 182 | } |
@@ -215,10 +239,11 @@ void QuicTransportStream::SignalOnData() |
215 | 239 | ReallocateBuffer(readableBytes); |
216 | 240 | } |
217 | 241 | owt_base::Frame frame; |
218 | | - frame.format = owt_base::FRAME_FORMAT_DATA; |
| 242 | + frame.format = owt_base::FRAME_FORMAT_I420; |
219 | 243 | frame.length = readableBytes; |
220 | 244 | frame.payload = m_buffer; |
221 | 245 | m_stream->Read(frame.payload, readableBytes); |
| 246 | + ELOG_ERROR("Delivery %d bytes.",frame.length); |
222 | 247 | deliverFrame(frame); |
223 | 248 | } |
224 | 249 | } |
|
0 commit comments