Live TV streaming (1 Viewer)

DieBagger

Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    41
    Austria
    Home Country
    Austria Austria
    For what parts do you need the webservices? To start timeshifting and get the rtsp streams? Couldn't you just include the tvserver dlls and write the method yourself (WebTvResult StartTimeShifting(int idChannel))?

    I'm not really good with VB but afaik it shouldn't be a problem using a c# dll in a vb project?!?
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,559
    312
    57
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    No - I can do the start timeshifting (it was already in iPiMP).

    My tests have shown much better transcoding results when I ffmpeg transcode the MPWebServices 'direct profile' stream rather than when I ffmpeg transcode the raw TV Server RTSP stream. The 'direct profile' seems to just read the input RTSP stream and copy it to an output stream using named pipes, so I was trying to implement that in iPiMP. Those methods are provided as *.cs files in the App_Code folder and so I can't just include them into my VB project. So I tried to translate them into VB but came accross a few differences between the languages - like VB not supporting Lamda expressions - I don't even know what that means :D

    My issue now is translating (NamedPipe.cs)
    Code:
    public override void Start(Boolean isClient)
            {
                if (isClient)
                {
                    NamedPipeClientStream client = new NamedPipeClientStream (".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
                    client.Connect(10000); // 10 second timeout.
    
                    pipe = client;
                    isReady = true;
                }
                else
                {
                    NamedPipeServerStream server = new NamedPipeServerStream(_pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
                    server.BeginWaitForConnection(new AsyncCallback(WaitForConnection), server);
                }
            }

    ends up as

    Code:
     Public Overloads Overrides Sub Start(ByVal isClient As Boolean)
                If isClient Then
                    Dim client As New NamedPipeClientStream(".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous)
                    client.Connect(10000) '10 second timeout.
                    pipe = client
                    m_isReady = True
                Else
                    Dim server As New NamedPipeServerStream(_pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous)
                    server.BeginWaitForConnection(New AsyncCallback(AddressOf WaitForConnection), server).AsyncWaitHandle.WaitOne(10000)
                    m_isReady = True
                End If
            End Sub
    
                   Private Sub WaitForConnection(ByVal ar As IAsyncResult)
                Try
                    Dim server As NamedPipeServerStream = TryCast(ar.AsyncState, NamedPipeServerStream)
                    server.EndWaitForConnection(ar)
    
                    pipe = server
                    m_isReady = True
                Catch ex As Exception
    
                End Try
            End Sub

    But the AsyncCallback(AddressOf WaitForConnection) never gets called by server.BeginWaitForConnection(New AsyncCallback(AddressOf WaitForConnection), server)

    Like I say - most of this is way over my head.
     

    DieBagger

    Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    41
    Austria
    Home Country
    Austria Austria
    Really hard to say from a distance, also I don't know what you already know so forgive me if I tell you something obvious (or even worse false ;)).

    First of all:

    Code:
    server.BeginWaitForConnection(New AsyncCallback(AddressOf WaitForConnection), server[B]).AsyncWaitHandle.WaitOne(10000)[/B]

    Why are you blocking the thread for 10000 ms, it isn't done in the c# original ;)? What you do with this is tell the NamedPipe to call the method WaitForConnection when the Pipe receives input. You get the input from your mencoder/ffmpeg which is registered in EncoderWrapper->StartProcess

    encoderOutput.UnderlyingStreamObject = applicationThread.StandardOutput.BaseStream;

    If "WaitForConnection" is never called you might want to check if the process is set up correctly (path of ffmpeg?). Do you see the console popup from ffmpeg when the transcoding starts btw?

    Hope that helped...
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,559
    312
    57
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    I amaze myself with my development noobishness sometimes.

    Progress today....took all the App_Code\*.cs and compiled them as a separate project and referenced this in my code. Duh!

    So now I get a different exception...

    Cannot process request because the process (3780) has exited.

    at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
    at System.Diagnostics.Process.Kill()
    at MediaPortal.TvServer.WebServices.EncoderWrapper.StopProcess() in D:\Dev\vs2008\MediaPortal Universal Web Interface\MPWebServices\EncoderWrapper.cs:line 192
    at Website.uWiMP.TVServer.Streamer.Stream(MediaType mediatype, Int32 id) in D:\Dev\vs2008\MediaPortal Universal Web Interface\Website\Code\TVServer\Streamer.vb:line 119
    at Website.WatchTVChannel.WatchChannel(String friendly, String channelID) in D:\Dev\vs2008\MediaPortal Universal Web Interface\Website\iPhone\TVGuide\WatchTVChannel.aspx.vb:line 83
    at Website.WatchTVChannel.Page_Load(Object sender, EventArgs e) in D:\Dev\vs2008\MediaPortal Universal Web Interface\Website\iPhone\TVGuide\WatchTVChannel.aspx.vb:line 68
    at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    Which I guess is the ffmpeg process exiting before it should. So that's what I'll be looking at next.
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,559
    312
    57
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    Woo Hoo!! I've got the streaming working, I had to modify MPWebServices a bit. You can see the changes I've done in the attachments.

    I still need to do a fair bit of work in iPiMP for navigation / stopping streaming etc. but the hard bit is done now (I HOPE!!!!)
     

    Attachments

    • config.zip
      493 bytes
    • MPWebServices.zip
      92.4 KB
    • Streamer.zip
      2.8 KB

    gemx

    Retired Team Member
  • Premium Supporter
  • October 31, 2006
    1,972
    539
    Home Country
    Germany Germany
    Hi cheezy,

    great work so far.
    If you have any further questions regarding the streaming in MPWebServices better drop me a PM directly.
    I don't have much time these days to read the forums and may easily miss an interesting post like yours :)

    I am still very interested in combining forces to create the perfect MP WebApp.
    To control the TvServer you can easily use the webservices from MPWebServices.
    You just need the .asmx file and the webservices.asmx.cs file in APP_Code and you have all you need to control TvServer ;)
     

    nicx

    Portal Pro
    February 1, 2006
    387
    12
    Stuttgart
    Home Country
    Germany Germany
    great news :)

    cheezy is your deadline still realistic? the world championship starts on friday ;)

    nicx...
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,559
    312
    57
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    I will do my best to get you an alpha version for Friday - I am already setting my alarm clock for 5am in order to get some time to work on this - I'll just set it an hour earlier! :D
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,559
    312
    57
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    Nearly there.

    I've also contacted the Smooth Streaming devs about handling streams with no video (e.g. Radio ;)) and they're having a look to see if it's feasible.
     

    Users who are viewing this thread

    Similar threads

    So, you're power cycling the TV, but not putting the PC to sleep ? In General => Startup/Resume settings, try checking "Ignore Windows resolution/size changes" In Codecs and Render, try selecting the specific audio device rather than "Default DirectSound device" Just ideas, no guarantee this will do anything. If this doesn't work, I...
    So, you're power cycling the TV, but not putting the PC to sleep ? In General => Startup/Resume settings, try checking "Ignore...
    I'm running MP1 as a client only on this: https://www.amazon.com/dp/B0DZX5DWS5?ref_=pe_123509780_1038749300_t_fed_asin_title&th=1...
    Replies
    4
    Views
    478
    MP1 MP2 MP2 - V2.3 EPG has stopped DE
    The only configuration that is certain to work is when the MP client and MP server are from the same release. It is sometimes possible to use MP clients from a release that is different to the MP server, but whether it works depends on the specific changes that were made between the two releases. -- from CyberSimian in the UK
    The only configuration that is certain to work is when the MP client and MP server are from the same release. It is sometimes...
    Before you create this bug report: Make sure that your system (Windows, codecs and drivers) is up to date, matching the...
    Replies
    10
    Views
    4K
    The reason I was thinking I needed more RAM is that TV now seems to be HiDef and so the files have grown. I edit the files before storing them, to reduce some size. It is finding that slower, I think. Or it could just be because I'm expecting more? The Baseboard manufacturer says ASUSTech Computer Inc; Baseboard product P7P55D-E...
    The reason I was thinking I needed more RAM is that TV now seems to be HiDef and so the files have grown. I edit the files before...
    I'm not sure where to post this query - I've been told, during a conversation about costs of upgrading, that W11 may not support my...
    Replies
    4
    Views
    4K
    I compliment you on the thoroughness of your investigations. (y) Unfortunately, I don't have any ideas what the problem might be. :( Perhaps someone else will post with some suggestions. :unsure: -- from CyberSimian in the UK
    I compliment you on the thoroughness of your investigations. (y) Unfortunately, I don't have any ideas what the problem might be...
    Would appreciate it if someone could solve (or point me in the right direction to resolve) this issue. I have “MultiSeat”...
    Replies
    4
    Views
    768
    Ok, thanks much. I will look into the instructions above. For the moment, I turned off the "Automatic channel logo update" in Settings (which somehow I had missed, I think because it wasn't an option previously), and the deleted everything in the Flat-default folder and populated it with my own logos. Works, so far.
    Ok, thanks much. I will look into the instructions above. For the moment, I turned off the "Automatic channel logo update" in...
    Hi-- I have to revisit an old issue, unfortunately. I just downloaded MP 2.5, a fresh installation, on a new computer (reluctantly...
    Replies
    5
    Views
    1K
    Top Bottom