| 2097 | }; |
| 2098 | |
| 2099 | void OnClientStreamCreated::Run() { |
| 2100 | std::unique_ptr<OnClientStreamCreated> delete_self(this); |
| 2101 | if (cntl.Failed()) { |
| 2102 | LOG(WARNING) << "Fail to create stream=" << stream->rtmp_url() |
| 2103 | << ": " << cntl.ErrorText(); |
| 2104 | return; |
| 2105 | } |
| 2106 | if (stream->_created_stream_with_play_or_publish) { |
| 2107 | // the server accepted the play/publish command packed in createStream |
| 2108 | return; |
| 2109 | } |
| 2110 | const RtmpClientStreamOptions& options = stream->options(); |
| 2111 | bool do_nothing = true; |
| 2112 | if (!options.play_name.empty()) { |
| 2113 | do_nothing = false; |
| 2114 | RtmpPlayOptions play_opt; |
| 2115 | play_opt.stream_name = options.play_name; |
| 2116 | if (stream->Play(play_opt) != 0) { |
| 2117 | LOG(WARNING) << "Fail to play " << options.play_name; |
| 2118 | return stream->SignalError(); |
| 2119 | } |
| 2120 | } |
| 2121 | if (!options.publish_name.empty()) { |
| 2122 | do_nothing = false; |
| 2123 | if (stream->Publish(options.publish_name, options.publish_type) != 0) { |
| 2124 | LOG(WARNING) << "Fail to publish " << stream->rtmp_url(); |
| 2125 | return stream->SignalError(); |
| 2126 | } |
| 2127 | } |
| 2128 | if (do_nothing) { |
| 2129 | LOG(ERROR) << "play_name and publish_name are both empty"; |
| 2130 | return stream->SignalError(); |
| 2131 | } |
| 2132 | } |
| 2133 | |
| 2134 | void RtmpClientStream::Init(const RtmpClient* client, |
| 2135 | const RtmpClientStreamOptions& options) { |
no test coverage detected