public void start() throws IllegalStateException {
   super.start();
   try {
     if (mode == MODE_STREAMING) {
       // receiver.getInputStream contains the data from the camera
       // the packetizer encapsulates this stream in an RTP stream and send it over the network
       packetizer.setInputStream(receiver.getInputStream());
       packetizer.start();
     }
     streaming = true;
   } catch (IOException e) {
     super.stop();
     throw new IllegalStateException("Something happened with the local sockets :/ Start failed");
   } catch (NullPointerException e) {
     super.stop();
     throw new IllegalStateException(
         "setPacketizer() should be called before start(). Start failed");
   }
 }
 public void stop() {
   if (streaming) {
     try {
       super.stop();
     } catch (Exception ignore) {
     } finally {
       super.reset();
       closeSockets();
       if (mode == MODE_STREAMING) packetizer.stop();
       streaming = false;
     }
   }
 }