[PATCH spice-streaming-server v2 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        | 3 ++-
 src/spice-streaming-agent.cpp | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index 192054a..404ee74 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::set<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 (codecs.find(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..6c300fa 100644
--- a/src/concrete-agent.hpp
+++ b/src/concrete-agent.hpp
@@ -7,6 +7,7 @@
 #define SPICE_STREAMING_AGENT_CONCRETE_AGENT_HPP
 
 #include <vector>
+#include <set>
 #include <memory>
 #include <spice-streaming-agent/plugin.hpp>
 
@@ -33,7 +34,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::set<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 608d2c7..56fcbe1 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::set<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.insert((SpiceVideoCodecType) msg[i]);
     return 1;
 }
 
@@ -372,7 +376,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]