kconbot: Introduction and Video Capabilities

I’ve started a new project this past week. For now I’m calling it “kconbot.”

Introduction

Kconbot is a gchat/gtalk bot I’m writing in Python using the xmpppy library. My goal is to make it capable of video chatting with users to stream video.

What’s the point? I’m calling it a “poor man’s home security system.” The idea is that you have kconbot running on a webcam-equipped computer in your home. The webcam is constantly on and the video image is checked to detect motion. If motion is detected, kconbot sends your main gchat account an instant message letting you know. Finally, you can initiate a video chat with kconbot, who auto-accepts the call, and you’re able to see a video feed of your home, hopefully quickly enough to see what caused the motion.

That’s the gist of the idea anyway. If I’m able to pull off that bit, I’d like to extend it in a number of ways. First and foremost, I’d like to get kconbot running on either a Raspberry Pi or Beaglebone. That would be attractive because those computer boards are low-power and ideal for a stand-alone application, so they don’t tie up one of my main computers.

But here’s where it can get cool:  what if in addition to video chat kconbot supports commands via chat? And what if the computer board kconbot was running on was attached to a small robot platform? You would be able to control the robot by sending chat messages to kconbot. So you could drive the robot around and see what it sees via the video chat. Wouldn’t that be awesome?

So ideally I can bang kconbot out in the next month or so before I start school. If I can get it done, I plan on releasing it as open-source on Github.

In the mean time, I’ll try to write a blog post if I’m able to accomplish something interesting.

Video Capabilities

After I got a basic XMPP/gchat bot up and running, the next step was to let the Google Talk servers know that kconbot is capable of video communication. Granted it’s not yet, but in preparation we’ve got to let Google’s servers know.

So here’s how to do just that using xmpppy. Once you’ve connected to the Google Talk server and authenticated, you have to send a Presence XMPP message. According to the Google Talk Call Signaling guide, you have to add a child XML element to the Presence stanza defining the capabilities of your client. Here’s where we define our video capability:

import xmpp

caps = xmpp.simplexml.Node(tag=’http://jabber.org/protocol/caps c’,attrs={‘node’:’http://mail.google.com/xmpp/client/caps’, ‘ver’:’1.0’, ‘ext’:’camera-v1 video-v1 voice-v1’})

conn.sendCustomPresence(node=caps)

"sendCustomPresence" is a method I added to the xmpppy Client class (I’m working with a local copy of xmpppy in my kconbot directory) in the client.py file:

def sendCustomPresence(self,jid=None,typ=None,requestRoster=0,node=None):

        “”” Send a presence state with a custom payload.

            Can also request roster from server if according argument is set.”“”

        pres = dispatcher.Presence(to=jid, typ=typ)

        pres.addChild(node=node)

        self.send(pres) 

 I’ll probably clean up how I’m handling this later, but for now, it works!

So here’s what kconbot looked like when viewed from my main gchat account running in the gmail widget BEFORE I added the video capability XML to my Presence stanza:

And here’s what it looks like after adding the video capability XML!

So there you have it! One step forward in making kconbot a reality!

comments powered by Disqus