diff --git a/LICENSE b/LICENSE index 57bc88a15..f9c96551c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - Apache License + Apache License!!! Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/README.md b/README.md index 45ca8020f..b57247efa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -## Open WebRTC Toolkit Media Server +## Open WebRTC Toolkit Media Server!!!@@@ + +remove The media server for OWT provides an efficient video conference and streaming service that is based on WebRTC. It scales a single WebRTC stream out to many endpoints. At the same time, it enables media analytics capabilities for media streams. It features: diff --git a/bad_44sec_10mb.mp4 b/bad_44sec_10mb.mp4 new file mode 100644 index 000000000..55c794cc7 Binary files /dev/null and b/bad_44sec_10mb.mp4 differ diff --git a/bad_7s.mp4 b/bad_7s.mp4 new file mode 100644 index 000000000..72cfb5941 Binary files /dev/null and b/bad_7s.mp4 differ diff --git a/scripts/release/daemon-bin.sh b/scripts/release/daemon-bin.sh index bc1b1ae29..e0ccbd731 100644 --- a/scripts/release/daemon-bin.sh +++ b/scripts/release/daemon-bin.sh @@ -219,6 +219,14 @@ case $startStop in fi ;; + (restart) + echo restarting $command + + ${0} stop $command + ${0} start $command + ;; + + (status) if [ -f $pid ]; then if ps -p `cat $pid` > /dev/null 2>&1; then diff --git a/source/agent/video/videoTranscoder/VideoFrameTranscoder.h b/source/agent/video/videoTranscoder/VideoFrameTranscoder.h index 2b941f5a0..d88fb45e8 100644 --- a/source/agent/video/videoTranscoder/VideoFrameTranscoder.h +++ b/source/agent/video/videoTranscoder/VideoFrameTranscoder.h @@ -39,6 +39,7 @@ class VideoFrameTranscoder { virtual void removeOutput(int output) = 0; virtual void requestKeyFrame(int output) = 0; + virtual void setMaxResolution(int output, int width, int height) = 0; #ifndef BUILD_FOR_ANALYTICS virtual void drawText(const std::string& textSpec) = 0; virtual void clearText() = 0; diff --git a/source/agent/video/videoTranscoder/VideoFrameTranscoderImpl.h b/source/agent/video/videoTranscoder/VideoFrameTranscoderImpl.h index 056ead4f7..fb2dafd44 100644 --- a/source/agent/video/videoTranscoder/VideoFrameTranscoderImpl.h +++ b/source/agent/video/videoTranscoder/VideoFrameTranscoderImpl.h @@ -66,6 +66,7 @@ class VideoFrameTranscoderImpl : public VideoFrameTranscoder, public owt_base::F void removeOutput(int output); void requestKeyFrame(int output); + void setMaxResolution(int output, int width, int height); #ifndef BUILD_FOR_ANALYTICS void drawText(const std::string& textSpec); void clearText(); @@ -283,6 +284,15 @@ inline void VideoFrameTranscoderImpl::requestKeyFrame(int output) if (it != m_outputs.end()) it->second.encoder->requestKeyFrame(it->second.streamId); } + +inline void VideoFrameTranscoderImpl::setMaxResolution(int output, int width, int height) +{ + boost::shared_lock lock(m_outputMutex); + auto it = m_outputs.find(output); + if (it != m_outputs.end()) + it->second.encoder->setMaxResolution(it->second.streamId, width, height); +} + #ifndef BUILD_FOR_ANALYTICS inline void VideoFrameTranscoderImpl::drawText(const std::string& textSpec) diff --git a/source/agent/video/videoTranscoder/VideoTranscoder.cpp b/source/agent/video/videoTranscoder/VideoTranscoder.cpp index c3d788c30..94d98c531 100644 --- a/source/agent/video/videoTranscoder/VideoTranscoder.cpp +++ b/source/agent/video/videoTranscoder/VideoTranscoder.cpp @@ -194,6 +194,23 @@ void VideoTranscoder::forceKeyFrame(const std::string& outStreamID) m_frameTranscoder->requestKeyFrame(index); } } + +void VideoTranscoder::setMaxResolution(const std::string& outStreamID, int width, int height) +{ + + int32_t index = -1; + boost::shared_lock lock(m_outputsMutex); + auto it = m_outputs.find(outStreamID); + if (it != m_outputs.end()) { + index = it->second; + } + lock.unlock(); + + if (index != -1) { + m_frameTranscoder->setMaxResolution(index, width, height); + } +} + #ifndef BUILD_FOR_ANALYTICS void VideoTranscoder::drawText(const std::string& textSpec) { diff --git a/source/agent/video/videoTranscoder/VideoTranscoder.h b/source/agent/video/videoTranscoder/VideoTranscoder.h index 86c786cfd..1732fbdc5 100644 --- a/source/agent/video/videoTranscoder/VideoTranscoder.h +++ b/source/agent/video/videoTranscoder/VideoTranscoder.h @@ -53,6 +53,7 @@ class VideoTranscoder { #endif void removeOutput(const std::string& outStreamID); void forceKeyFrame(const std::string& outStreamID); + void setMaxResolution(const std::string& outStreamID, int width, int height); #ifndef BUILD_FOR_ANALYTICS void drawText(const std::string& textSpec); void clearText(); diff --git a/source/agent/video/videoTranscoder/VideoTranscoderWrapper.cpp b/source/agent/video/videoTranscoder/VideoTranscoderWrapper.cpp index bbf1fa8f0..8529d9717 100644 --- a/source/agent/video/videoTranscoder/VideoTranscoderWrapper.cpp +++ b/source/agent/video/videoTranscoder/VideoTranscoderWrapper.cpp @@ -176,6 +176,26 @@ void VideoTranscoder::forceKeyFrame(const v8::FunctionCallbackInfo& a me->forceKeyFrame(outStreamID); } +void VideoTranscoder::setMaxResolution(const v8::FunctionCallbackInfo& args){ + + Isolate* isolate = Isolate::GetCurrent(); + HandleScope scope(isolate); + + VideoTranscoder* obj = ObjectWrap::Unwrap(args.Holder()); + mcu::VideoTranscoder* me = obj->me; + + String::Utf8Value param0(args[0]->ToString()); + String::Utf8Value param1(args[1]->ToString()); + String::Utf8Value param2(args[2]->ToString()); + + std::string outStreamID = std::string(*param0); + int width = std::stoi(std::string(*param1)); + int height = std::stoi(std::string(*param2)); + + me->setMaxResolution(outStreamID, width, height); +} + + #ifndef BUILD_FOR_ANALYTICS void VideoTranscoder::drawText(const v8::FunctionCallbackInfo& args) { Isolate* isolate = Isolate::GetCurrent(); diff --git a/source/agent/video/videoTranscoder/VideoTranscoderWrapper.h b/source/agent/video/videoTranscoder/VideoTranscoderWrapper.h index ad69d1e13..bd22195ff 100644 --- a/source/agent/video/videoTranscoder/VideoTranscoderWrapper.h +++ b/source/agent/video/videoTranscoder/VideoTranscoderWrapper.h @@ -33,6 +33,7 @@ class VideoTranscoder : public node::ObjectWrap { static void addOutput(const v8::FunctionCallbackInfo& args); static void removeOutput(const v8::FunctionCallbackInfo& args); static void forceKeyFrame(const v8::FunctionCallbackInfo& args); + static void setMaxResolution(const v8::FunctionCallbackInfo& args); #ifndef BUILD_FOR_ANLAYTICS static void drawText(const v8::FunctionCallbackInfo& args); static void clearText(const v8::FunctionCallbackInfo& args); diff --git a/source/core/owt_base/AVStreamOut.cpp b/source/core/owt_base/AVStreamOut.cpp index a6856bb46..accdce4b6 100644 --- a/source/core/owt_base/AVStreamOut.cpp +++ b/source/core/owt_base/AVStreamOut.cpp @@ -163,6 +163,7 @@ void AVStreamOut::onFrame(const owt_base::Frame& frame) } if (!m_videoSourceChanged + && frame.additionalInfo.video.width != 0 && (m_width != frame.additionalInfo.video.width || m_height != frame.additionalInfo.video.height)) { ELOG_DEBUG("Video resolution changed %dx%d -> %dx%d", diff --git a/source/core/owt_base/MediaFramePipeline.h b/source/core/owt_base/MediaFramePipeline.h index 13c95cd0a..de16c3a7c 100644 --- a/source/core/owt_base/MediaFramePipeline.h +++ b/source/core/owt_base/MediaFramePipeline.h @@ -302,7 +302,19 @@ class VideoFrameEncoder : public FrameDestination { virtual void degenerateStream(int32_t streamId) = 0; virtual void setBitrate(unsigned short kbps, int32_t streamId) = 0; virtual void requestKeyFrame(int32_t streamId) = 0; + +protected: + int maxWidth = 0; + int maxHeight = 0; }; + + +inline void VideoFrameEncoder::setMaxResolution(int output, int width, int height) +{ + maxWidth = width; + maxHeight = height; +} + } #endif diff --git a/source/core/owt_base/VCMFrameEncoder.cpp b/source/core/owt_base/VCMFrameEncoder.cpp index 79a8aa681..56d6c987e 100644 --- a/source/core/owt_base/VCMFrameEncoder.cpp +++ b/source/core/owt_base/VCMFrameEncoder.cpp @@ -384,16 +384,34 @@ void VCMFrameEncoder::encode(boost::shared_ptr frame) } if (m_width != frame->width() || m_height != frame->height()) { - ELOG_DEBUG_T("Update encoder resolution %dx%d->%dx%d", m_width, m_height, frame->width(), frame->height()); - ret = m_encoder->SetResolution(frame->width(), frame->height()); + int new_width = 0; + int new_height = 0; + + if(maxWidth > 0 && frame->width() > maxWidth){ + new_width = maxWidth; + new_height = (int) ( static_cast(new_width) / (static_cast(frame->width()) / static_cast(frame->height())) ); + }else if(maxHeight > 0 && frame->height() > maxHeight){ + new_height = maxHeight; + new_width = (int) ( static_cast(new_height) * ( static_cast(frame->width()) / static_cast(frame->height()) ) ); + }else{ + new_width = frame->width(); + new_height = frame->height(); + } + + + ELOG_DEBUG_T("Update encoder resolution %dx%d, %dx%d->%dx%d", frame->width(), frame->height(), m_width, m_height, new_width, new_height); + + ret = m_encoder->SetResolution(new_width, new_height); if (ret != 0) { ELOG_WARN_T("Update Encode size error: %d", ret); } m_width = frame->width(); m_height = frame->height(); - m_updateBitrateKbps = calcBitrate(m_width, m_height, m_frameRate); + + m_updateBitrateKbps = calcBitrate(new_width, new_height, m_frameRate); + } if (m_updateBitrateKbps) { diff --git a/source/management_console/public/js/libapi.js b/source/management_console/public/js/libapi.js index 76464ca65..405055999 100644 --- a/source/management_console/public/js/libapi.js +++ b/source/management_console/public/js/libapi.js @@ -93,7 +93,7 @@ function calculateSignature (toSign, key) { function ManagementApi (spec) { this.id = spec.id; this.key = spec.key; - this.url = spec.url || '/'; + this.url = spec.url || window.location.pathname.replace(/\/console.*/g, "/"); this.send = function (method, body, url, callback) { // callback (err, resp) var service = this.id; var key = this.key;