home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
WebService and Mobile Access
Self Contained Web Server / Interface
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Big_Kev" data-source="post: 312676" data-attributes="member: 52102"><p>I use CreateProcess windows API from within the application, and keep track of the ProcessID. Each card gets a separate instance of VLC as it has a different stream URL. I use the Process ID to kill the process when I want to stop it.</p><p></p><p>[CODE]</p><p>void __fastcall TMPWebSvr::StartStreaming(int CardID, AnsiString FileName)</p><p>{</p><p>AnsiString AppExe = "\"" + IncludeTrailingBackslash(VLCPath) + "vlc.exe\"";</p><p></p><p>if (FileName.IsEmpty())</p><p> AppExe += " rtsp://" + VLCServer + "/stream" + CardID + ".0";</p><p>else</p><p> {</p><p> VLCStreams->File[CardID] = FileName;</p><p> int Pos = FileName.Pos("\\");</p><p> while (Pos > 0)</p><p> {</p><p> FileName.Delete(Pos, 1);</p><p> FileName.Insert("/", Pos);</p><p> Pos = FileName.Pos("\\");</p><p> }</p><p> AppExe += " file:///\"" + FileName +"\"";</p><p> }</p><p></p><p>AppExe += " :sout=#transcode{" + VLCStreams->Transcode[CardID] + "}</p><p>:duplicate{dst=std{access=http,mux=ts,dst=" + VLCServer + ":" + VLCStreams->Port[CardID] + "}} :sout-keep";</p><p></p><p>AnsiString Desktop = "default";</p><p>AnsiString StartDir = "";</p><p></p><p>bool WaitForReturn = false;</p><p></p><p>AnsiString LogString = Now().FormatString("c") + " - Preparing to stream on card " + AnsiString(CardID)+" - Command = " + AppExe + "\r\n";</p><p>if (LogStream == NULL)</p><p> LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone);</p><p>LogStream->Write(LogString.c_str(), LogString.Length());</p><p></p><p>PROCESS_INFORMATION pi;</p><p>STARTUPINFO si;</p><p></p><p>ZeroMemory(&pi, sizeof(pi));</p><p>ZeroMemory(&si, sizeof(si));</p><p>si.cb = sizeof(si);</p><p></p><p>si.lpDesktop = Desktop.c_str();</p><p></p><p>VLCStreams->ProcessID[CardID] = 0;</p><p></p><p>bool Success = false;</p><p>try</p><p> {</p><p> if(::CreateProcess(NULL, AppExe.c_str(), NULL, NULL, false, DETACHED_PROCESS|NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))</p><p> {</p><p> VLCStreams->ProcessID[CardID] = pi.dwProcessId;</p><p> CloseHandle(pi.hProcess);</p><p> CloseHandle(pi.hThread);</p><p> }</p><p> }</p><p>catch(Sysutils::Exception &e)</p><p> {</p><p> AnsiString Message = e.Message;</p><p> }</p><p>if (VLCStreams->ProcessID[CardID])</p><p> {</p><p> AnsiString LogString = Now().FormatString("c") + " - Streaming started on card " + AnsiString(CardID)+"\r\n";</p><p> if (LogStream == NULL)</p><p> LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone);</p><p> LogStream->Write(LogString.c_str(), LogString.Length());</p><p> }</p><p>}</p><p>//---------------------------------------------------------------------------</p><p></p><p>void __fastcall TMPWebSvr::StopStreaming(int CardID)</p><p>{</p><p>// Stop VLC Instance created for streaming...</p><p>if (VLCStreams->ProcessID[CardID]) // Check that this instance is still runninig...</p><p> {</p><p> try</p><p> {</p><p> HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, VLCStreams->ProcessID[CardID]);</p><p> ULONG ExitCode;</p><p> GetExitCodeProcess(ProcessHandle, &ExitCode);</p><p> TerminateProcess(ProcessHandle, ExitCode);</p><p> CloseHandle(ProcessHandle);</p><p> AnsiString LogString = Now().FormatString("c") + " - Stop streaming on card " + AnsiString(CardID)+"\r\n";</p><p> if (LogStream == NULL)</p><p> LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone);</p><p> LogStream->Write(LogString.c_str(), LogString.Length());</p><p></p><p> }</p><p> catch(...)</p><p> {</p><p> }</p><p> VLCStreams->ProcessID[CardID] = 0;</p><p> VLCStreams->File[CardID] = "";</p><p> }</p><p>}</p><p>//---------------------------------------------------------------------------</p><p>[/CODE]</p><p></p><p>You can see the command used in the live log in the new version.</p><p></p><p>Kev</p></blockquote><p></p>
[QUOTE="Big_Kev, post: 312676, member: 52102"] I use CreateProcess windows API from within the application, and keep track of the ProcessID. Each card gets a separate instance of VLC as it has a different stream URL. I use the Process ID to kill the process when I want to stop it. [CODE] void __fastcall TMPWebSvr::StartStreaming(int CardID, AnsiString FileName) { AnsiString AppExe = "\"" + IncludeTrailingBackslash(VLCPath) + "vlc.exe\""; if (FileName.IsEmpty()) AppExe += " rtsp://" + VLCServer + "/stream" + CardID + ".0"; else { VLCStreams->File[CardID] = FileName; int Pos = FileName.Pos("\\"); while (Pos > 0) { FileName.Delete(Pos, 1); FileName.Insert("/", Pos); Pos = FileName.Pos("\\"); } AppExe += " file:///\"" + FileName +"\""; } AppExe += " :sout=#transcode{" + VLCStreams->Transcode[CardID] + "} :duplicate{dst=std{access=http,mux=ts,dst=" + VLCServer + ":" + VLCStreams->Port[CardID] + "}} :sout-keep"; AnsiString Desktop = "default"; AnsiString StartDir = ""; bool WaitForReturn = false; AnsiString LogString = Now().FormatString("c") + " - Preparing to stream on card " + AnsiString(CardID)+" - Command = " + AppExe + "\r\n"; if (LogStream == NULL) LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone); LogStream->Write(LogString.c_str(), LogString.Length()); PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.lpDesktop = Desktop.c_str(); VLCStreams->ProcessID[CardID] = 0; bool Success = false; try { if(::CreateProcess(NULL, AppExe.c_str(), NULL, NULL, false, DETACHED_PROCESS|NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { VLCStreams->ProcessID[CardID] = pi.dwProcessId; CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } } catch(Sysutils::Exception &e) { AnsiString Message = e.Message; } if (VLCStreams->ProcessID[CardID]) { AnsiString LogString = Now().FormatString("c") + " - Streaming started on card " + AnsiString(CardID)+"\r\n"; if (LogStream == NULL) LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone); LogStream->Write(LogString.c_str(), LogString.Length()); } } //--------------------------------------------------------------------------- void __fastcall TMPWebSvr::StopStreaming(int CardID) { // Stop VLC Instance created for streaming... if (VLCStreams->ProcessID[CardID]) // Check that this instance is still runninig... { try { HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, VLCStreams->ProcessID[CardID]); ULONG ExitCode; GetExitCodeProcess(ProcessHandle, &ExitCode); TerminateProcess(ProcessHandle, ExitCode); CloseHandle(ProcessHandle); AnsiString LogString = Now().FormatString("c") + " - Stop streaming on card " + AnsiString(CardID)+"\r\n"; if (LogStream == NULL) LogStream = new TFileStream(IncludeTrailingBackslash(ServicePath) + "MPWebInt.log", fmCreate | fmShareDenyNone); LogStream->Write(LogString.c_str(), LogString.Length()); } catch(...) { } VLCStreams->ProcessID[CardID] = 0; VLCStreams->File[CardID] = ""; } } //--------------------------------------------------------------------------- [/CODE] You can see the command used in the live log in the new version. Kev [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
WebService and Mobile Access
Self Contained Web Server / Interface
Contact us
RSS
Top
Bottom