Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer setSource & play causing long hangs

QMediaPlayer setSource & play causing long hangs

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 4 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Which version of Qt are you using ?
    On which platform ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Which version of Qt are you using ?
      On which platform ?

      S Offline
      S Offline
      swurl
      wrote on last edited by
      #3

      @SGaist Qt 6.6.0. This occurs on both Windows and Linux. Unsure if it occurs on MacOS, but given the circumstances of high-latency, bandwidth-limited streams I expect it to happen there too.

      C 1 Reply Last reply
      0
      • S swurl

        @SGaist Qt 6.6.0. This occurs on both Windows and Linux. Unsure if it occurs on MacOS, but given the circumstances of high-latency, bandwidth-limited streams I expect it to happen there too.

        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #4

        @swurl Self-contained example code and stream please.

        S 1 Reply Last reply
        0
        • C ChrisW67

          @swurl Self-contained example code and stream please.

          S Offline
          S Offline
          swurl
          wrote on last edited by
          #5

          @ChrisW67 I really don't know any reproducible streams. The issue moreso lies in the fact that it's synchronously waiting for the connection to be established and stable and pausing the exec loop entirely.

          jsulmJ 1 Reply Last reply
          0
          • S swurl

            @ChrisW67 I really don't know any reproducible streams. The issue moreso lies in the fact that it's synchronously waiting for the connection to be established and stable and pausing the exec loop entirely.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @swurl said in QMediaPlayer setSource & play causing long hangs:

            I really don't know any reproducible streams

            Then how do you test and know that you have long hangs?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply
            0
            • jsulmJ jsulm

              @swurl said in QMediaPlayer setSource & play causing long hangs:

              I really don't know any reproducible streams

              Then how do you test and know that you have long hangs?

              S Offline
              S Offline
              swurl
              wrote on last edited by
              #7

              @jsulm The streams are confined to the specific ecosystem of FRC. If you have a remote camera server running that streams latent MJPG streams, however, you should get the same results.

              S 1 Reply Last reply
              0
              • S swurl

                @jsulm The streams are confined to the specific ecosystem of FRC. If you have a remote camera server running that streams latent MJPG streams, however, you should get the same results.

                S Offline
                S Offline
                swurl
                wrote on last edited by
                #8

                @swurl More specifically, some streams coming from this ecosystem tend towards very high (>400ms) latency with really long connection times, particularly due to strict bandwidth limitations of 4Mbps. I think you can recreate this through an artificially high ping when connecting, not sure how to create that though.

                C 1 Reply Last reply
                0
                • S Offline
                  S Offline
                  swurl
                  wrote on last edited by
                  #9

                  Bumping this again...

                  I found that this sometimes occurs when a connection fails or you have a really slow (<10Mbps) connection and try to connect to a large file stream.

                  I will post an example code soon.

                  1 Reply Last reply
                  0
                  • SGaistS SGaist referenced this topic on
                  • S swurl

                    @swurl More specifically, some streams coming from this ecosystem tend towards very high (>400ms) latency with really long connection times, particularly due to strict bandwidth limitations of 4Mbps. I think you can recreate this through an artificially high ping when connecting, not sure how to create that though.

                    C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by
                    #10

                    @swurl To establish any TCP connection over a link where packets take greater than 400mS to transit from one end to the other is going to take at least 3 times that period (a SYN, SYN/ACK, ACK handshake). So with an unreliable connection establishment time > 1.2 seconds and a what I assume is a 10-second timeout baked into the Qt library, you will occasionally fall foul of it. Qt cannot make a slow line or remote server faster, or make an unreliable link reliable.

                    Since you have not provided example code and stream it is hard to say what can be done to improve the situation.
                    Can you at least disclose exactly how you are setting the source for the media player?
                    Are you passing it an already open and running QIODevice or relying on the media code to open a stream from a URL? The former option is the only approach I can think of that might decouple the opening and the playing.

                    S 2 Replies Last reply
                    0
                    • C ChrisW67

                      @swurl To establish any TCP connection over a link where packets take greater than 400mS to transit from one end to the other is going to take at least 3 times that period (a SYN, SYN/ACK, ACK handshake). So with an unreliable connection establishment time > 1.2 seconds and a what I assume is a 10-second timeout baked into the Qt library, you will occasionally fall foul of it. Qt cannot make a slow line or remote server faster, or make an unreliable link reliable.

                      Since you have not provided example code and stream it is hard to say what can be done to improve the situation.
                      Can you at least disclose exactly how you are setting the source for the media player?
                      Are you passing it an already open and running QIODevice or relying on the media code to open a stream from a URL? The former option is the only approach I can think of that might decouple the opening and the playing.

                      S Offline
                      S Offline
                      swurl
                      wrote on last edited by
                      #11

                      @ChrisW67 said in QMediaPlayer setSource & play causing long hangs:

                      Qt cannot make a slow line or remote server faster, or make an unreliable link reliable.

                      This I fully understand. However, loading on a browser takes <2 seconds. I'm curious if I'm doing something wrong regarding how I'm doing it.

                      I'm simply using setSource and play right now.

                      I'll try the QIODevice thing though, and let you know how it goes...

                      1 Reply Last reply
                      0
                      • C ChrisW67

                        @swurl To establish any TCP connection over a link where packets take greater than 400mS to transit from one end to the other is going to take at least 3 times that period (a SYN, SYN/ACK, ACK handshake). So with an unreliable connection establishment time > 1.2 seconds and a what I assume is a 10-second timeout baked into the Qt library, you will occasionally fall foul of it. Qt cannot make a slow line or remote server faster, or make an unreliable link reliable.

                        Since you have not provided example code and stream it is hard to say what can be done to improve the situation.
                        Can you at least disclose exactly how you are setting the source for the media player?
                        Are you passing it an already open and running QIODevice or relying on the media code to open a stream from a URL? The former option is the only approach I can think of that might decouple the opening and the playing.

                        S Offline
                        S Offline
                        swurl
                        wrote on last edited by
                        #12

                        @ChrisW67 OK, i'm a little confused. How should I go about using the QIODevice for remote files? This is contacting a stream and I don't see any documentation on using a streamed remote file with a QIODevice...

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          swurl
                          wrote on last edited by
                          #13

                          Nevermind, I figured it out...

                          So it seems that setSource reasonably expects you to actually have stopped the media beforehand. Doing so and adding a small wait works like a charm and fixes this issue!

                          Relevant example.

                          m_player->stop();
                          
                              QThread::msleep(100);
                          
                              m_player->setSource(url);
                              m_player->play();
                          
                          1 Reply Last reply
                          0
                          • S swurl has marked this topic as solved on
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            You could also use the playbackState property to trigger the new play once it gets in the stopped state.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved