Skip to content
Permalink
Browse files

Add placeholders to bifrost-webrtc

  • Loading branch information...
ZizhengTai committed Sep 17, 2019
1 parent 37c22ef commit d0a9046a2f477ba61d49582c7c5362522cca6f58
Showing with 61 additions and 12 deletions.
  1. +5 −5 Cargo.toml
  2. +3 −0 bifrost-webrtc/Cargo.toml
  3. +48 −0 bifrost-webrtc/src/codec.rs
  4. +4 −7 bifrost-webrtc/src/lib.rs
  5. +1 −0 bifrost-webrtc/src/peer_connection.rs
@@ -20,8 +20,8 @@ members = [
]

[dependencies]
bifrost-ice = { version = "0.1.0-alpha", path = "bifrost-ice" }
bifrost-sdp = { version = "0.1.0", path = "bifrost-sdp" }
bifrost-stun = { version = "0.1.0-alpha", path = "bifrost-stun" }
bifrost-turn = { version = "0.1.0-alpha", path = "bifrost-turn" }
bifrost-webrtc = { version = "0.1.0-alpha", path = "bifrost-webrtc" }
bifrost-ice = { version = "=0.1.0-alpha", path = "bifrost-ice" }
bifrost-sdp = { version = "=0.1.0", path = "bifrost-sdp" }
bifrost-stun = { version = "=0.1.0-alpha", path = "bifrost-stun" }
bifrost-turn = { version = "=0.1.0-alpha", path = "bifrost-turn" }
bifrost-webrtc = { version = "=0.1.0-alpha", path = "bifrost-webrtc" }
@@ -11,3 +11,6 @@ repository = "https://github.com/bifrost-rs/bifrost"
readme = "README.md"

[dependencies]
bifrost-stun = { version = "=0.1.0-alpha", path = "../bifrost-stun" }
bytes = "0.4"
tokio-codec = "=0.2.0-alpha.4"
@@ -0,0 +1,48 @@
use bifrost_stun::codec::MessageCodec;
use bifrost_stun::message::Message;
use bytes::BytesMut;
use std::io;
use tokio_codec::Decoder;

pub enum MuxMessage {
Stun(Message),
Unknown,
}

pub struct MuxDecoder {
stun: MessageCodec,
}

impl Default for MuxDecoder {
fn default() -> Self {
Self {
stun: MessageCodec::default(),
}
}
}

impl MuxDecoder {
// TODO: Remove allow
#[allow(dead_code)]
pub fn new() -> Self {
Self::default()
}
}

impl Decoder for MuxDecoder {
type Item = MuxMessage;
type Error = io::Error;

fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
match self.stun.decode(src) {
Ok(Some(Some(item))) => return Ok(Some(MuxMessage::Stun(item))),
Ok(Some(None)) => (),
Ok(None) => return Ok(None),
Err(e) => return Err(e),
}

// TODO: Try next decoder

Ok(Some(MuxMessage::Unknown))
}
}
@@ -1,7 +1,4 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
mod codec;
mod peer_connection;

pub use self::peer_connection::PeerConnection;
@@ -0,0 +1 @@
pub struct PeerConnection;

0 comments on commit d0a9046

Please sign in to comment.
You can’t perform that action at this time.