Use a second camera and switch between them.

Also, blink out the state over the beacon.

Change-Id: If606dfed9ae64137f71429f1190f04d5dac2c4ec
diff --git a/aos/vision/events/udp.cc b/aos/vision/events/udp.cc
index 4c0437b..660342c 100644
--- a/aos/vision/events/udp.cc
+++ b/aos/vision/events/udp.cc
@@ -26,8 +26,8 @@
   return send(fd_.get(), data, size, 0);
 }
 
-RXUdpSocket::RXUdpSocket(int port)
-    : fd_(PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))) {
+int RXUdpSocket::SocketBindListenOnPort(int port) {
+  int fd = PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
   sockaddr_in bind_address;
   memset(&bind_address, 0, sizeof(bind_address));
 
@@ -35,10 +35,13 @@
   bind_address.sin_port = htons(port);
   bind_address.sin_addr.s_addr = htonl(INADDR_ANY);
 
-  PCHECK(bind(fd_.get(), reinterpret_cast<sockaddr *>(&bind_address),
+  PCHECK(bind(fd, reinterpret_cast<sockaddr *>(&bind_address),
               sizeof(bind_address)));
+  return fd;
 }
 
+RXUdpSocket::RXUdpSocket(int port) : fd_(SocketBindListenOnPort(port)) {}
+
 int RXUdpSocket::Recv(void *data, int size) {
   return PCHECK(recv(fd_.get(), static_cast<char *>(data), size, 0));
 }
diff --git a/aos/vision/events/udp.h b/aos/vision/events/udp.h
index ed4a8e7..9a23dab 100644
--- a/aos/vision/events/udp.h
+++ b/aos/vision/events/udp.h
@@ -30,6 +30,24 @@
   DISALLOW_COPY_AND_ASSIGN(TXUdpSocket);
 };
 
+// Send a protobuf.  Not RT (mallocs on send).
+template <typename PB>
+class ProtoTXUdpSocket {
+ public:
+  ProtoTXUdpSocket(const std::string &ip_addr, int port)
+      : socket_(ip_addr, port) {}
+
+  void Send(const PB &pb) {
+    ::std::string serialized_data;
+    pb.SerializeToString(&serialized_data);
+    socket_.Send(serialized_data.data(), serialized_data.size());
+  }
+
+ private:
+  TXUdpSocket socket_;
+  DISALLOW_COPY_AND_ASSIGN(ProtoTXUdpSocket);
+};
+
 // Simple wrapper around a receiving UDP socket.
 //
 // LOG(FATAL)s for all errors, including from Recv.
@@ -40,6 +58,8 @@
   // Returns the number of bytes received.
   int Recv(void *data, int size);
 
+  static int SocketBindListenOnPort(int port);
+
  private:
   ScopedFD fd_;