$ git clone http://tcclient.ion.nu/tc_client.git
commit 493c324a072ccbb83d9c4f50471415660bff99ec
Author: Alicia <...>
Date:   Wed May 4 16:31:44 2016 +0200

    Added a /closecam command to stop receiving a cam stream.

diff --git a/ChangeLog b/ChangeLog
index c68dd53..1618458 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 0.39:
+Added a /closecam command to stop receiving a cam stream.
 modbot: only use youtube-dl's 'ytsearch:' for --get-id, and only if it doesn't appear to be an ID already.
 tc_client-gtk: handle only one sendmessage event at a time, and don't send empty lines.
 tc_client-gtk: added postprocessing options for cams upon right-click, starting with brightness adjustment.
diff --git a/README b/README
index 9977e08..8136c3b 100644
--- a/README
+++ b/README
@@ -10,6 +10,7 @@ Commands supported by tc_client:
 /colors         = list the available colors
 /nick <newnick> = change nickname
 /opencam <nick> = see someone's cam/mic (Warning: writes binary data to stdout)
+/closecam <nick> = stop receiving someone's cam stream
 /close <nick>   = close someone's cam/mic stream (as a mod)
 /ban <nick>     = ban someone
 /banlist        = list who is banned
diff --git a/client.c b/client.c
index 581a916..091acf9 100644
--- a/client.c
+++ b/client.c
@@ -507,6 +507,7 @@ int main(int argc, char** argv)
                  "/nick <newnick> = changes your nickname\n"
                  "/msg <to> <msg> = send a private message\n"
                  "/opencam <nick> = see someone's cam/mic (Warning: writes binary data to stdout)\n"
+                 "/closecam <nick> = stop receiving someone's cam stream\n"
                  "/close <nick>   = close someone's cam/mic stream (as a mod)\n"
                  "/ban <nick>     = ban someone\n"
                  "/banlist        = list who is banned\n"
@@ -580,6 +581,11 @@ int main(int argc, char** argv)
           stream_start(&buf[9], sock);
           continue;
         }
+        else if(!strncmp(buf, "/closecam ", 10))
+        {
+          stream_stopvideo(sock, idlist_get(&buf[10]));
+          continue;
+        }
         else if(!strncmp(buf, "/close ", 7)) // Stop someone's cam/mic broadcast
         {
           char nick[strlen(&buf[7])+1];
@@ -680,7 +686,7 @@ int main(int argc, char** argv)
         }
         else if(!strcmp(buf, "/camdown"))
         {
-          stream_stopvideo(sock);
+          stream_stopvideo(sock, idlist_get(nickname));
           continue;
         }
         else if(!strncmp(buf, "/video ", 7)) // Send video data
diff --git a/media.c b/media.c
index a45b85f..0e7b725 100644
--- a/media.c
+++ b/media.c
@@ -129,26 +129,7 @@ void stream_handlestatus(struct amf* amf, int sock)
   if(!strcmp(code->string.string, "NetStream.Play.Stop"))
   {
     unsigned int id=strtoul(details->string.string, 0, 0);
-    unsigned int i;
-    for(i=0; i<streamcount; ++i)
-    {
-      if(streams[i].userid==id)
-      {
-        printf("VideoEnd: %u\n", streams[i].userid);
-        // Delete the stream
-        struct rtmp amf;
-        amfinit(&amf, 3);
-        amfstring(&amf, "deleteStream");
-        amfnum(&amf, 0);
-        amfnull(&amf);
-        amfnum(&amf, streams[i].streamid);
-        amfsend(&amf, sock);
-        // Remove from list of streams
-        --streamcount;
-        memmove(&streams[i], &streams[i+1], sizeof(struct stream)*(streamcount-i));
-        return;
-      }
-    }
+    stream_stopvideo(sock, id);
   }
 }
 
@@ -171,12 +152,12 @@ void stream_sendvideo(int sock, void* buf, size_t len)
   }
 }
 
-void stream_stopvideo(int sock)
+void stream_stopvideo(int sock, unsigned int id)
 {
   unsigned int i;
   for(i=0; i<streamcount; ++i)
   {
-    if(streams[i].outgoing)
+    if(streams[i].userid==id)
     {
       struct rtmp amf;
       // Close the stream
diff --git a/media.h b/media.h
index 25195ab..67a1478 100644
--- a/media.h
+++ b/media.h
@@ -32,4 +32,4 @@ extern void stream_play(struct amf* amf, int sock); // called upon _result
 extern void stream_handledata(struct rtmp* rtmp);
 extern void stream_handlestatus(struct amf* amf, int sock);
 extern void stream_sendvideo(int sock, void* buf, size_t len);
-extern void stream_stopvideo(int sock);
+extern void stream_stopvideo(int sock, unsigned int id);