Live TV streaming (1 Viewer)

DieBagger

Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    39
    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,560
    312
    55
    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
    39
    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,560
    312
    55
    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,560
    312
    55
    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,560
    312
    55
    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,560
    312
    55
    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

    I need to try MadVR, I hope my Intel NAC can manage it.
    I need to try MadVR, I hope my Intel NAC can manage it.
    Remember PAL DVDs of US movies and TV Shows, and how they were converted to 25 fps thus introducing a "smurf lite" pitch on the...
    Replies
    2
    Views
    340
    It's working after some hours search: the Auto3D plugin which I haven't used for years was corrupting the start of the TV live stream from server to MP. If anyone has a similar problem - disable all old plugins and then enable one after another :-)
    It's working after some hours search: the Auto3D plugin which I haven't used for years was corrupting the start of the TV live...
    After using MP for more than 10 years with regularly updates - this is the first time that after an update MP is not working...
    Replies
    3
    Views
    1K
    Hi, First off: there are some issues with the latest Mediaportal (32bits vs 64bits), so that is one of the issues you're stumbling with. If you take the previous version (1.31) it should work as expected. For IPTV there is also a different option (with different pros and cons): Onlinevideos. I'm using that sometimes for my IPTV as...
    Hi, First off: there are some issues with the latest Mediaportal (32bits vs 64bits), so that is one of the issues you're stumbling...
    Hi I am trying to play a m3u file from my IPTV provider, but when I try to install the TV part of Media Portal v1.3.2 I get an...
    Replies
    1
    Views
    659
    Since updating the BIOS and the audio driver two weeks ago, I have not experienced the above problem again.
    Since updating the BIOS and the audio driver two weeks ago, I have not experienced the above problem again.
    Occasionally if I pause Live TV then resume it later, the video keeps playing but the audio is stuck in a half second loop. As of...
    Replies
    4
    Views
    897
    Please read here how to report problems.
    Please read here how to report problems.
    Before I start with the problem in detail, please confirm this is the correct thread for this issue. Server and client worked until...
    Replies
    1
    Views
    741
    Top Bottom