media-sharing: Add an initial skelleton for the repo including
  client and server boilerplate.

Change-Id: I76631db4b7127e960b133edb786a0db1b5832e01
diff --git a/.gitignore b/.gitignore
index b7e2fde..f447f7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-/.v23
\ No newline at end of file
+/.v23
+go/pkg/
+go/bin/
\ No newline at end of file
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..574583c
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,9 @@
+# This is the official list of Vanadium authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+
+# Names should be added to this file as:
+#   Name or Organization <email address>
+# The email address is not required for organizations.
+
+# Please keep the list sorted.
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
new file mode 100644
index 0000000..a15b95c
--- /dev/null
+++ b/CONTRIBUTORS
@@ -0,0 +1,13 @@
+# People who have agreed to one of the CLAs and can contribute patches.
+# The AUTHORS file lists the copyright holders; this file
+# lists people.  For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# https://developers.google.com/open-source/cla/individual
+# https://developers.google.com/open-source/cla/corporate
+#
+# Names should be added to this file as:
+#     Name <email address>
+Benjamin Prosnitz <bprosnitz@google.com>
+Matt Rosencrantz <mattr@google.com>
+Nicolas LaCasse <nlacasse@google.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..411db13
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2015 The Vanadium Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+   * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/PATENTS b/PATENTS
new file mode 100644
index 0000000..d52cc55
--- /dev/null
+++ b/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Vanadium project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Vanadium, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Vanadium. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Vanadium or any code incorporated within this
+implementation of Vanadium constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Vanadium
+shall terminate as of the date such litigation is filed.
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6d6ff85
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+v23-0.1
diff --git a/go/src/v.io/x/media_sharing/media.vdl b/go/src/v.io/x/media_sharing/media.vdl
new file mode 100644
index 0000000..104b4ea
--- /dev/null
+++ b/go/src/v.io/x/media_sharing/media.vdl
@@ -0,0 +1,19 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package media_sharing
+
+type MediaSharing interface {
+ // DisplayURL will cause the server to display whatever media is at
+ // the given URL.  The server will rely on the ContentType response
+ // header it gets when fetching the url to decide how to display
+ // the media.
+  DisplayUrl(url string) error
+
+ // DisplayBytes will cause the server to display whatever media is
+ // sent in the stream.  In the case of audio or movie media, the
+ // media should be played while the data is streaming.  The mediaType
+ // can be used by the server to decide how to display the media.
+ DisplayBytes(mediaType string) stream<[]byte, _> error
+}
diff --git a/go/src/v.io/x/media_sharing/media.vdl.go b/go/src/v.io/x/media_sharing/media.vdl.go
new file mode 100644
index 0000000..7899003
--- /dev/null
+++ b/go/src/v.io/x/media_sharing/media.vdl.go
@@ -0,0 +1,287 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file was auto-generated by the vanadium vdl tool.
+// Source: media.vdl
+
+package media_sharing
+
+import (
+	// VDL system imports
+	"io"
+	"v.io/v23"
+	"v.io/v23/context"
+	"v.io/v23/rpc"
+)
+
+// MediaSharingClientMethods is the client interface
+// containing MediaSharing methods.
+type MediaSharingClientMethods interface {
+	// DisplayURL will cause the server to display whatever media is at
+	// the given URL.  The server will rely on the ContentType response
+	// header it gets when fetching the url to decide how to display
+	// the media.
+	DisplayUrl(ctx *context.T, url string, opts ...rpc.CallOpt) error
+	// DisplayBytes will cause the server to display whatever media is
+	// sent in the stream.  In the case of audio or movie media, the
+	// media should be played while the data is streaming.  The mediaType
+	// can be used by the server to decide how to display the media.
+	DisplayBytes(ctx *context.T, mediaType string, opts ...rpc.CallOpt) (MediaSharingDisplayBytesClientCall, error)
+}
+
+// MediaSharingClientStub adds universal methods to MediaSharingClientMethods.
+type MediaSharingClientStub interface {
+	MediaSharingClientMethods
+	rpc.UniversalServiceMethods
+}
+
+// MediaSharingClient returns a client stub for MediaSharing.
+func MediaSharingClient(name string) MediaSharingClientStub {
+	return implMediaSharingClientStub{name}
+}
+
+type implMediaSharingClientStub struct {
+	name string
+}
+
+func (c implMediaSharingClientStub) DisplayUrl(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) {
+	err = v23.GetClient(ctx).Call(ctx, c.name, "DisplayUrl", []interface{}{i0}, nil, opts...)
+	return
+}
+
+func (c implMediaSharingClientStub) DisplayBytes(ctx *context.T, i0 string, opts ...rpc.CallOpt) (ocall MediaSharingDisplayBytesClientCall, err error) {
+	var call rpc.ClientCall
+	if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "DisplayBytes", []interface{}{i0}, opts...); err != nil {
+		return
+	}
+	ocall = &implMediaSharingDisplayBytesClientCall{ClientCall: call}
+	return
+}
+
+// MediaSharingDisplayBytesClientStream is the client stream for MediaSharing.DisplayBytes.
+type MediaSharingDisplayBytesClientStream interface {
+	// SendStream returns the send side of the MediaSharing.DisplayBytes client stream.
+	SendStream() interface {
+		// Send places the item onto the output stream.  Returns errors
+		// encountered while sending, or if Send is called after Close or
+		// the stream has been canceled.  Blocks if there is no buffer
+		// space; will unblock when buffer space is available or after
+		// the stream has been canceled.
+		Send(item []byte) error
+		// Close indicates to the server that no more items will be sent;
+		// server Recv calls will receive io.EOF after all sent items.
+		// This is an optional call - e.g. a client might call Close if it
+		// needs to continue receiving items from the server after it's
+		// done sending.  Returns errors encountered while closing, or if
+		// Close is called after the stream has been canceled.  Like Send,
+		// blocks if there is no buffer space available.
+		Close() error
+	}
+}
+
+// MediaSharingDisplayBytesClientCall represents the call returned from MediaSharing.DisplayBytes.
+type MediaSharingDisplayBytesClientCall interface {
+	MediaSharingDisplayBytesClientStream
+	// Finish performs the equivalent of SendStream().Close, then blocks until
+	// the server is done, and returns the positional return values for the call.
+	//
+	// Finish returns immediately if the call has been canceled; depending on the
+	// timing the output could either be an error signaling cancelation, or the
+	// valid positional return values from the server.
+	//
+	// Calling Finish is mandatory for releasing stream resources, unless the call
+	// has been canceled or any of the other methods return an error.  Finish should
+	// be called at most once.
+	Finish() error
+}
+
+type implMediaSharingDisplayBytesClientCall struct {
+	rpc.ClientCall
+}
+
+func (c *implMediaSharingDisplayBytesClientCall) SendStream() interface {
+	Send(item []byte) error
+	Close() error
+} {
+	return implMediaSharingDisplayBytesClientCallSend{c}
+}
+
+type implMediaSharingDisplayBytesClientCallSend struct {
+	c *implMediaSharingDisplayBytesClientCall
+}
+
+func (c implMediaSharingDisplayBytesClientCallSend) Send(item []byte) error {
+	return c.c.Send(item)
+}
+func (c implMediaSharingDisplayBytesClientCallSend) Close() error {
+	return c.c.CloseSend()
+}
+func (c *implMediaSharingDisplayBytesClientCall) Finish() (err error) {
+	err = c.ClientCall.Finish()
+	return
+}
+
+// MediaSharingServerMethods is the interface a server writer
+// implements for MediaSharing.
+type MediaSharingServerMethods interface {
+	// DisplayURL will cause the server to display whatever media is at
+	// the given URL.  The server will rely on the ContentType response
+	// header it gets when fetching the url to decide how to display
+	// the media.
+	DisplayUrl(ctx *context.T, call rpc.ServerCall, url string) error
+	// DisplayBytes will cause the server to display whatever media is
+	// sent in the stream.  In the case of audio or movie media, the
+	// media should be played while the data is streaming.  The mediaType
+	// can be used by the server to decide how to display the media.
+	DisplayBytes(ctx *context.T, call MediaSharingDisplayBytesServerCall, mediaType string) error
+}
+
+// MediaSharingServerStubMethods is the server interface containing
+// MediaSharing methods, as expected by rpc.Server.
+// The only difference between this interface and MediaSharingServerMethods
+// is the streaming methods.
+type MediaSharingServerStubMethods interface {
+	// DisplayURL will cause the server to display whatever media is at
+	// the given URL.  The server will rely on the ContentType response
+	// header it gets when fetching the url to decide how to display
+	// the media.
+	DisplayUrl(ctx *context.T, call rpc.ServerCall, url string) error
+	// DisplayBytes will cause the server to display whatever media is
+	// sent in the stream.  In the case of audio or movie media, the
+	// media should be played while the data is streaming.  The mediaType
+	// can be used by the server to decide how to display the media.
+	DisplayBytes(ctx *context.T, call *MediaSharingDisplayBytesServerCallStub, mediaType string) error
+}
+
+// MediaSharingServerStub adds universal methods to MediaSharingServerStubMethods.
+type MediaSharingServerStub interface {
+	MediaSharingServerStubMethods
+	// Describe the MediaSharing interfaces.
+	Describe__() []rpc.InterfaceDesc
+}
+
+// MediaSharingServer returns a server stub for MediaSharing.
+// It converts an implementation of MediaSharingServerMethods into
+// an object that may be used by rpc.Server.
+func MediaSharingServer(impl MediaSharingServerMethods) MediaSharingServerStub {
+	stub := implMediaSharingServerStub{
+		impl: impl,
+	}
+	// Initialize GlobState; always check the stub itself first, to handle the
+	// case where the user has the Glob method defined in their VDL source.
+	if gs := rpc.NewGlobState(stub); gs != nil {
+		stub.gs = gs
+	} else if gs := rpc.NewGlobState(impl); gs != nil {
+		stub.gs = gs
+	}
+	return stub
+}
+
+type implMediaSharingServerStub struct {
+	impl MediaSharingServerMethods
+	gs   *rpc.GlobState
+}
+
+func (s implMediaSharingServerStub) DisplayUrl(ctx *context.T, call rpc.ServerCall, i0 string) error {
+	return s.impl.DisplayUrl(ctx, call, i0)
+}
+
+func (s implMediaSharingServerStub) DisplayBytes(ctx *context.T, call *MediaSharingDisplayBytesServerCallStub, i0 string) error {
+	return s.impl.DisplayBytes(ctx, call, i0)
+}
+
+func (s implMediaSharingServerStub) Globber() *rpc.GlobState {
+	return s.gs
+}
+
+func (s implMediaSharingServerStub) Describe__() []rpc.InterfaceDesc {
+	return []rpc.InterfaceDesc{MediaSharingDesc}
+}
+
+// MediaSharingDesc describes the MediaSharing interface.
+var MediaSharingDesc rpc.InterfaceDesc = descMediaSharing
+
+// descMediaSharing hides the desc to keep godoc clean.
+var descMediaSharing = rpc.InterfaceDesc{
+	Name:    "MediaSharing",
+	PkgPath: "v.io/x/media_sharing",
+	Methods: []rpc.MethodDesc{
+		{
+			Name: "DisplayUrl",
+			Doc:  "// DisplayURL will cause the server to display whatever media is at\n// the given URL.  The server will rely on the ContentType response\n// header it gets when fetching the url to decide how to display\n// the media.",
+			InArgs: []rpc.ArgDesc{
+				{"url", ``}, // string
+			},
+		},
+		{
+			Name: "DisplayBytes",
+			Doc:  "// DisplayBytes will cause the server to display whatever media is\n// sent in the stream.  In the case of audio or movie media, the \n// media should be played while the data is streaming.  The mediaType\n// can be used by the server to decide how to display the media.",
+			InArgs: []rpc.ArgDesc{
+				{"mediaType", ``}, // string
+			},
+		},
+	},
+}
+
+// MediaSharingDisplayBytesServerStream is the server stream for MediaSharing.DisplayBytes.
+type MediaSharingDisplayBytesServerStream interface {
+	// RecvStream returns the receiver side of the MediaSharing.DisplayBytes server stream.
+	RecvStream() interface {
+		// Advance stages an item so that it may be retrieved via Value.  Returns
+		// true iff there is an item to retrieve.  Advance must be called before
+		// Value is called.  May block if an item is not available.
+		Advance() bool
+		// Value returns the item that was staged by Advance.  May panic if Advance
+		// returned false or was not called.  Never blocks.
+		Value() []byte
+		// Err returns any error encountered by Advance.  Never blocks.
+		Err() error
+	}
+}
+
+// MediaSharingDisplayBytesServerCall represents the context passed to MediaSharing.DisplayBytes.
+type MediaSharingDisplayBytesServerCall interface {
+	rpc.ServerCall
+	MediaSharingDisplayBytesServerStream
+}
+
+// MediaSharingDisplayBytesServerCallStub is a wrapper that converts rpc.StreamServerCall into
+// a typesafe stub that implements MediaSharingDisplayBytesServerCall.
+type MediaSharingDisplayBytesServerCallStub struct {
+	rpc.StreamServerCall
+	valRecv []byte
+	errRecv error
+}
+
+// Init initializes MediaSharingDisplayBytesServerCallStub from rpc.StreamServerCall.
+func (s *MediaSharingDisplayBytesServerCallStub) Init(call rpc.StreamServerCall) {
+	s.StreamServerCall = call
+}
+
+// RecvStream returns the receiver side of the MediaSharing.DisplayBytes server stream.
+func (s *MediaSharingDisplayBytesServerCallStub) RecvStream() interface {
+	Advance() bool
+	Value() []byte
+	Err() error
+} {
+	return implMediaSharingDisplayBytesServerCallRecv{s}
+}
+
+type implMediaSharingDisplayBytesServerCallRecv struct {
+	s *MediaSharingDisplayBytesServerCallStub
+}
+
+func (s implMediaSharingDisplayBytesServerCallRecv) Advance() bool {
+	s.s.errRecv = s.s.Recv(&s.s.valRecv)
+	return s.s.errRecv == nil
+}
+func (s implMediaSharingDisplayBytesServerCallRecv) Value() []byte {
+	return s.s.valRecv
+}
+func (s implMediaSharingDisplayBytesServerCallRecv) Err() error {
+	if s.s.errRecv == io.EOF {
+		return nil
+	}
+	return s.s.errRecv
+}
diff --git a/go/src/v.io/x/media_sharing/media_sharing.go b/go/src/v.io/x/media_sharing/media_sharing.go
new file mode 100644
index 0000000..3fbd6ee
--- /dev/null
+++ b/go/src/v.io/x/media_sharing/media_sharing.go
@@ -0,0 +1,13 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package media_sharing
+
+import (
+	"fmt"
+)
+
+func main() {
+	fmt.Printf("hello\n")
+}
diff --git a/go/src/v.io/x/media_sharing/mediaclient/mediaclient.go b/go/src/v.io/x/media_sharing/mediaclient/mediaclient.go
new file mode 100644
index 0000000..e3dd976
--- /dev/null
+++ b/go/src/v.io/x/media_sharing/mediaclient/mediaclient.go
@@ -0,0 +1,39 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+	"fmt"
+	"os"
+
+	"v.io/v23/context"
+	"v.io/x/lib/cmdline"
+	"v.io/x/media_sharing"
+	"v.io/x/ref/lib/v23cmd"
+	_ "v.io/x/ref/runtime/factories/static"
+)
+
+func main() {
+	cmdline.Main(root)
+}
+
+var root = &cmdline.Command{
+	Name:     os.Args[0],
+	ArgsName: "<server> <url>",
+	ArgsLong: ("<server> is the Vanadium name of a media server.  " +
+		"<url> is an url to some content."),
+	Runner: v23cmd.RunnerFunc(display),
+	Short:  "Share media with a remote display.",
+}
+
+func display(ctx *context.T, env *cmdline.Env, args []string) error {
+	if len(args) < 2 {
+		return fmt.Errorf("Both a server and url must be specified.")
+	}
+	name, url := args[0], args[1]
+	client := media_sharing.MediaSharingClient(name)
+
+	return client.DisplayUrl(ctx, url)
+}
diff --git a/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go b/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go
new file mode 100644
index 0000000..7d48c4c
--- /dev/null
+++ b/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go
@@ -0,0 +1,72 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+	"fmt"
+	"os"
+
+	"v.io/v23"
+	"v.io/v23/context"
+	"v.io/v23/rpc"
+	"v.io/x/lib/cmdline"
+	"v.io/x/media_sharing"
+	"v.io/x/ref/lib/signals"
+	"v.io/x/ref/lib/v23cmd"
+	_ "v.io/x/ref/runtime/factories/static"
+)
+
+func main() {
+	cmdline.Main(root)
+}
+
+var root = &cmdline.Command{
+	Name:     os.Args[0],
+	ArgsName: "<name>",
+	ArgsLong: "<name> Is the name to mount the server under.",
+	Runner:   v23cmd.RunnerFunc(serve),
+	Short:    "Serve a display to remote clients.",
+}
+
+func serve(ctx *context.T, env *cmdline.Env, args []string) error {
+	name := ""
+	if len(args) > 0 {
+		name = args[0]
+	}
+
+	server, err := v23.NewServer(ctx)
+	if err != nil {
+		return err
+	}
+	eps, err := server.Listen(v23.GetListenSpec(ctx))
+	if err != nil {
+		return err
+	}
+	if err := server.Serve(name, media_sharing.MediaSharingServer(&media{}), nil); err != nil {
+		return err
+	}
+	fmt.Printf("Listening at: %s", eps[0].Name())
+
+	<-signals.ShutdownOnSignals(ctx)
+	return nil
+}
+
+type media struct{}
+
+// DisplayURL will cause the server to display whatever media is at
+// the given URL.  The server will rely on the ContentType response
+// header it gets when fetching the url to decide how to display
+// the media.
+func (m *media) DisplayUrl(ctx *context.T, call rpc.ServerCall, url string) error {
+	return nil
+}
+
+// DisplayBytes will cause the server to display whatever media is
+// sent in the stream.  In the case of audio or movie media, the
+// media should be played while the data is streaming.  The mediaType
+// can be used by the server to decide how to display the media.
+func (m *media) DisplayBytes(ctx *context.T, call media_sharing.MediaSharingDisplayBytesServerCall, mediaType string) error {
+	return nil
+}