[PATCH spice-streaming-server 3/3] Do not use an encoding not supported by the client

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows for instance old clients to work correctly.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 src/concrete-agent.cpp        | 5 ++++-
 src/concrete-agent.hpp        | 2 +-
 src/spice-streaming-agent.cpp | 6 +++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index 192054a..53beeab 100644
--- a/src/concrete-agent.cpp
+++ b/src/concrete-agent.cpp
@@ -98,7 +98,7 @@ void ConcreteAgent::LoadPlugin(const char *plugin_filename)
     }
 }
 
-FrameCapture *ConcreteAgent::GetBestFrameCapture()
+FrameCapture *ConcreteAgent::GetBestFrameCapture(const std::vector<SpiceVideoCodecType>& codecs)
 {
     vector<pair<unsigned, shared_ptr<Plugin>>> sorted_plugins;
 
@@ -113,6 +113,9 @@ FrameCapture *ConcreteAgent::GetBestFrameCapture()
         if (plugin.first == DontUse) {
             break;
         }
+        // check client supports the codec
+        if (find(codecs.begin(), codecs.end(), plugin.second->VideoCodecType()) == codecs.end())
+            continue;
         FrameCapture *capture = plugin.second->CreateCapture();
         if (capture) {
             return capture;
diff --git a/src/concrete-agent.hpp b/src/concrete-agent.hpp
index 828368b..c5920c6 100644
--- a/src/concrete-agent.hpp
+++ b/src/concrete-agent.hpp
@@ -33,7 +33,7 @@ public:
     void LoadPlugins(const char *directory);
     // pointer must remain valid
     void AddOption(const char *name, const char *value);
-    FrameCapture *GetBestFrameCapture();
+    FrameCapture *GetBestFrameCapture(const std::vector<SpiceVideoCodecType>& codecs);
     bool PluginVersionIsCompatible(unsigned pluginVersion) const override;
 private:
     void LoadPlugin(const char *plugin_filename);
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index ff43804..67fa7e2 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -51,6 +51,7 @@ typedef struct {
 } SpiceStreamDataMessage;
 
 static int streaming_requested;
+static std::vector<SpiceVideoCodecType> client_codecs;
 static bool quit;
 static int streamfd = -1;
 static bool stdin_ok;
@@ -142,6 +143,9 @@ static int read_command_from_device(void)
     streaming_requested = msg[0]; /* num_codecs */
     syslog(LOG_INFO, "GOT START_STOP message -- request to %s streaming\n",
            streaming_requested ? "START" : "STOP");
+    client_codecs.clear();
+    for (int i = 1; i <= msg[0]; ++i)
+        client_codecs.push_back((SpiceVideoCodecType) msg[i]);
     return 1;
 }
 
@@ -370,7 +374,7 @@ do_capture(const char *streamport, FILE *f_log)
         syslog(LOG_INFO, "streaming starts now\n");
         uint64_t time_last = 0;
 
-        std::unique_ptr<FrameCapture> capture(agent.GetBestFrameCapture());
+        std::unique_ptr<FrameCapture> capture(agent.GetBestFrameCapture(client_codecs));
         if (!capture)
             throw std::runtime_error("cannot find a suitable capture system");
 
-- 
2.13.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]